@@ -37,6 +37,10 @@ def udp_parse(self, data, **kw):
3737 raise Exception (f'{ self .name } don\' t support UDP server' )
3838 def udp_connect (self , rauth , host_name , port , data , ** kw ):
3939 raise Exception (f'{ self .name } don\' t support UDP client' )
40+ def udp_client (self , data ):
41+ return data
42+ def udp_client2 (self , host_name , port , data ):
43+ return data
4044 async def connect (self , reader_remote , writer_remote , rauth , host_name , port , ** kw ):
4145 raise Exception (f'{ self .name } don\' t support client' )
4246 async def channel (self , reader , writer , stat_bytes , stat_conn ):
@@ -143,6 +147,17 @@ def udp_parse(self, data, auth, **kw):
143147 return
144148 host_name , port = socks_address (reader , n )
145149 return host_name , port , reader .read ()
150+ def udp_client (self , data ):
151+ reader = io .BytesIO (data )
152+ n = reader .read (1 )[0 ]
153+ host_name , port = socks_address (reader , n )
154+ return reader .read ()
155+ def udp_client2 (self , host_name , port , data ):
156+ try :
157+ return b'\x01 ' + socket .inet_aton (host_name ) + port .to_bytes (2 , 'big' ) + data
158+ except Exception :
159+ pass
160+ return b'\x03 ' + packstr (host_name .encode ()) + port .to_bytes (2 , 'big' ) + data
146161 def udp_connect (self , rauth , host_name , port , data , ** kw ):
147162 return rauth + b'\x03 ' + packstr (host_name .encode ()) + port .to_bytes (2 , 'big' ) + data
148163
0 commit comments