wordfilter_client 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/gen.txt +1 -1
- data/doc/wordfilter.thrift +22 -1
- data/lib/word_filters_service.rb +106 -0
- data/lib/wordfilter_client/version.rb +1 -1
- data/lib/wordfilter_types.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09d9bda4af57fe26fe37c2eaa8b643b5d0fa48cb
|
4
|
+
data.tar.gz: d0fb998d66b0ada52027700a381d7b0832cfda00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c1a48e46c4986f8cc0de7e9defa0b366222e7d609938f3ebc922051be48fb9374e6fe88ab0c0a011eb24ad9fde57f2e1163a5a82c8a01ddbacb31bd3ee47b75
|
7
|
+
data.tar.gz: 25b96d78220ee436ea24efc565c7e6576528929dd1530982009267234a3463a1e4fdc70d8f6390e395b64bf1076ce11928ef5e2297b70933b917797e43eb3089
|
data/doc/gen.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
thrift -out /workspaces/ruby/wordfilter-client/lib/
|
1
|
+
thrift -out /workspaces/ruby/wordfilter-client/lib/ --gen rb /workspaces/ruby/wordfilter-client/doc/wordfilter.thrift
|
data/doc/wordfilter.thrift
CHANGED
@@ -6,7 +6,7 @@ namespace rb wordfilter.thrift
|
|
6
6
|
*/
|
7
7
|
struct PartResult{
|
8
8
|
1:i32 error,
|
9
|
-
2:string part
|
9
|
+
2:optional string part
|
10
10
|
}
|
11
11
|
|
12
12
|
/**
|
@@ -46,6 +46,8 @@ service WordFiltersService {
|
|
46
46
|
* -13:IP对应的主机重复发帖过于频繁 <br />
|
47
47
|
* -14:因为用户之前重复发帖,而被禁止操作 <br />
|
48
48
|
* -15:因为该IP对应主机重复发帖,而被禁止操作 <br />
|
49
|
+
* -17 用户违反验证码限制 <br/>
|
50
|
+
* -18 IP违反验证码限制 <br/>
|
49
51
|
* -99:未知的应用
|
50
52
|
* @throws IOException
|
51
53
|
*/
|
@@ -98,5 +100,24 @@ service WordFiltersService {
|
|
98
100
|
*/
|
99
101
|
i32 onlyWordFilter(1:i32 application, 2:i64 userId, 3:string ip,
|
100
102
|
4:string txtData);
|
103
|
+
|
104
|
+
/**
|
105
|
+
* 验证应用是否需要提示验证码,违反了频率控制
|
106
|
+
* @param application
|
107
|
+
* @param userId
|
108
|
+
* @param ip
|
109
|
+
* @return
|
110
|
+
*/
|
111
|
+
bool checkCaptcha(1:i32 application, 2:i64 userId, 3:string ip);
|
112
|
+
|
113
|
+
/**
|
114
|
+
* 清空用户,IP的调用记录
|
115
|
+
* @param application
|
116
|
+
* @param userId
|
117
|
+
* @param ip
|
118
|
+
*/
|
119
|
+
oneway void clearCaptcha(1:i32 application, 2:i64 userId, 3:string ip);
|
101
120
|
}
|
102
121
|
|
122
|
+
|
123
|
+
|
data/lib/word_filters_service.rb
CHANGED
@@ -88,6 +88,28 @@ module Wordfilter
|
|
88
88
|
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'onlyWordFilter failed: unknown result')
|
89
89
|
end
|
90
90
|
|
91
|
+
def checkCaptcha(application, userId, ip)
|
92
|
+
send_checkCaptcha(application, userId, ip)
|
93
|
+
return recv_checkCaptcha()
|
94
|
+
end
|
95
|
+
|
96
|
+
def send_checkCaptcha(application, userId, ip)
|
97
|
+
send_message('checkCaptcha', CheckCaptcha_args, :application => application, :userId => userId, :ip => ip)
|
98
|
+
end
|
99
|
+
|
100
|
+
def recv_checkCaptcha()
|
101
|
+
result = receive_message(CheckCaptcha_result)
|
102
|
+
return result.success unless result.success.nil?
|
103
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'checkCaptcha failed: unknown result')
|
104
|
+
end
|
105
|
+
|
106
|
+
def clearCaptcha(application, userId, ip)
|
107
|
+
send_clearCaptcha(application, userId, ip)
|
108
|
+
end
|
109
|
+
|
110
|
+
def send_clearCaptcha(application, userId, ip)
|
111
|
+
send_message('clearCaptcha', ClearCaptcha_args, :application => application, :userId => userId, :ip => ip)
|
112
|
+
end
|
91
113
|
end
|
92
114
|
|
93
115
|
class Processor
|
@@ -128,6 +150,19 @@ module Wordfilter
|
|
128
150
|
write_result(result, oprot, 'onlyWordFilter', seqid)
|
129
151
|
end
|
130
152
|
|
153
|
+
def process_checkCaptcha(seqid, iprot, oprot)
|
154
|
+
args = read_args(iprot, CheckCaptcha_args)
|
155
|
+
result = CheckCaptcha_result.new()
|
156
|
+
result.success = @handler.checkCaptcha(args.application, args.userId, args.ip)
|
157
|
+
write_result(result, oprot, 'checkCaptcha', seqid)
|
158
|
+
end
|
159
|
+
|
160
|
+
def process_clearCaptcha(seqid, iprot, oprot)
|
161
|
+
args = read_args(iprot, ClearCaptcha_args)
|
162
|
+
@handler.clearCaptcha(args.application, args.userId, args.ip)
|
163
|
+
return
|
164
|
+
end
|
165
|
+
|
131
166
|
end
|
132
167
|
|
133
168
|
# HELPER FUNCTIONS AND STRUCTURES
|
@@ -322,6 +357,77 @@ module Wordfilter
|
|
322
357
|
::Thrift::Struct.generate_accessors self
|
323
358
|
end
|
324
359
|
|
360
|
+
class CheckCaptcha_args
|
361
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
362
|
+
APPLICATION = 1
|
363
|
+
USERID = 2
|
364
|
+
IP = 3
|
365
|
+
|
366
|
+
FIELDS = {
|
367
|
+
APPLICATION => {:type => ::Thrift::Types::I32, :name => 'application'},
|
368
|
+
USERID => {:type => ::Thrift::Types::I64, :name => 'userId'},
|
369
|
+
IP => {:type => ::Thrift::Types::STRING, :name => 'ip'}
|
370
|
+
}
|
371
|
+
|
372
|
+
def struct_fields; FIELDS; end
|
373
|
+
|
374
|
+
def validate
|
375
|
+
end
|
376
|
+
|
377
|
+
::Thrift::Struct.generate_accessors self
|
378
|
+
end
|
379
|
+
|
380
|
+
class CheckCaptcha_result
|
381
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
382
|
+
SUCCESS = 0
|
383
|
+
|
384
|
+
FIELDS = {
|
385
|
+
SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'}
|
386
|
+
}
|
387
|
+
|
388
|
+
def struct_fields; FIELDS; end
|
389
|
+
|
390
|
+
def validate
|
391
|
+
end
|
392
|
+
|
393
|
+
::Thrift::Struct.generate_accessors self
|
394
|
+
end
|
395
|
+
|
396
|
+
class ClearCaptcha_args
|
397
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
398
|
+
APPLICATION = 1
|
399
|
+
USERID = 2
|
400
|
+
IP = 3
|
401
|
+
|
402
|
+
FIELDS = {
|
403
|
+
APPLICATION => {:type => ::Thrift::Types::I32, :name => 'application'},
|
404
|
+
USERID => {:type => ::Thrift::Types::I64, :name => 'userId'},
|
405
|
+
IP => {:type => ::Thrift::Types::STRING, :name => 'ip'}
|
406
|
+
}
|
407
|
+
|
408
|
+
def struct_fields; FIELDS; end
|
409
|
+
|
410
|
+
def validate
|
411
|
+
end
|
412
|
+
|
413
|
+
::Thrift::Struct.generate_accessors self
|
414
|
+
end
|
415
|
+
|
416
|
+
class ClearCaptcha_result
|
417
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
418
|
+
|
419
|
+
FIELDS = {
|
420
|
+
|
421
|
+
}
|
422
|
+
|
423
|
+
def struct_fields; FIELDS; end
|
424
|
+
|
425
|
+
def validate
|
426
|
+
end
|
427
|
+
|
428
|
+
::Thrift::Struct.generate_accessors self
|
429
|
+
end
|
430
|
+
|
325
431
|
end
|
326
432
|
|
327
433
|
end
|
data/lib/wordfilter_types.rb
CHANGED
@@ -16,7 +16,7 @@ module Wordfilter
|
|
16
16
|
|
17
17
|
FIELDS = {
|
18
18
|
ERROR => {:type => ::Thrift::Types::I32, :name => 'error'},
|
19
|
-
PART => {:type => ::Thrift::Types::STRING, :name => 'part'}
|
19
|
+
PART => {:type => ::Thrift::Types::STRING, :name => 'part', :optional => true}
|
20
20
|
}
|
21
21
|
|
22
22
|
def struct_fields; FIELDS; end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wordfilter_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gavin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thrift-client
|