r_socks 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f65a9692996d13a3e33f77e96ecabbd2a1af1c44fc6bd3bc415e9b019ff3a0d9
4
- data.tar.gz: 274824294f22fd40c66006229a54139192b1e68048906c5b488d3def328bed54
3
+ metadata.gz: 1a7150f7711b2fa8807f99ae87e082947488effb625c3da5a5e4e6467a818535
4
+ data.tar.gz: 7ab0d14e24184b511036e325d1f003611f53306f2e266f88ef0cb2f52561e37a
5
5
  SHA512:
6
- metadata.gz: 804e9a02adbe5a2ef196da2ddf51cefa8076ce2fae15c39b0e86480e3e011d42983f173ef2f54aa3c251925bdc9dcfa23c517f29d4f28d8b850a76a1c2217e60
7
- data.tar.gz: 66bcd6d353d3135985fb8c00a1b803e1d7b1f71b9af5effcc70785ce6b157a27131805ca6b6eaf9390b3558d423fcfe11ccbf6f5a5379bf3bc5ed5edb96b647c
6
+ metadata.gz: 1869580601e5c4795cc7f050f8f4683b2c07d7382a7d09b74831bf32fbe3083abf18121a6308649887999e75fc00a809225286cf228deb7491916044656ebac5
7
+ data.tar.gz: 5e925d6a0b96ca93041a15221f47654f79bea9149afb9363d8aa2b5575f4d1baaa1a8221aa0ae4faacd66664311d55f27b031baef3a25099e705d702561a9324
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- r_socks (0.1.5)
4
+ r_socks (0.1.7)
5
5
  eventmachine (~> 1.2, >= 1.2.7)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # RSocks
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/r_socks`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ this is a socks5 server base on Eventmachine.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ can be using as socks5 proxy server side.
6
6
 
7
7
  ## Installation
8
8
 
@@ -44,13 +44,6 @@ server.config.auth_method = :password
44
44
  server.run!
45
45
  ```
46
46
 
47
-
48
- ## Development
49
-
50
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
51
-
52
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
53
-
54
47
  ## Contributing
55
48
 
56
49
  Bug reports and pull requests are welcome on GitHub at https://github.com/nickoan/r_socks.
@@ -61,10 +61,10 @@ module RSocks
61
61
  return send_data(not_accept) unless @state_machine.start?
62
62
 
63
63
  if @target.nil?
64
- @target = EventMachine.connect(@addr, @port, RSocks::TargetConnectionHandler, self)
64
+ @target = EventMachine.connect(@addr, @port, RSocks::TargetConnectionHandler, self, data)
65
65
  end
66
66
 
67
- @target.send_data(data)
67
+ proxy_incoming_to(@target,60000)
68
68
  rescue => error
69
69
  puts "Error at #{@ip}:#{@port}, message: #{data}, error: #{error.message}"
70
70
  puts error.backtrace
@@ -72,7 +72,12 @@ module RSocks
72
72
  end
73
73
 
74
74
  def unbind
75
- @target.close_connection if @target
75
+ stop_proxying
76
+ @target.close_connection_after_writing if @target
77
+ end
78
+
79
+ def proxy_target_unbound
80
+ close_connection
76
81
  end
77
82
 
78
83
  private
@@ -3,12 +3,22 @@ require 'eventmachine'
3
3
  module RSocks
4
4
  class TargetConnectionHandler < EM::Connection
5
5
 
6
- def initialize(client)
6
+ def initialize(client, data)
7
7
  @client = client
8
+ @init_data = data
8
9
  end
9
10
 
10
- def receive_data(data)
11
- @client.send_data(data)
11
+ def post_init
12
+ proxy_incoming_to(@client,60000)
13
+ end
14
+
15
+ def connection_completed
16
+ send_data @init_data
17
+ @init_data = nil
18
+ end
19
+
20
+ def proxy_target_unbound
21
+ close_connection
12
22
  end
13
23
 
14
24
  def unbind
@@ -1,3 +1,3 @@
1
1
  module RSocks
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r_socks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick An
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-22 00:00:00.000000000 Z
11
+ date: 2020-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine