@@ -141,7 +141,6 @@ func (h *packetHandler) Handle(clientConn net.PacketConn) {
141
141
break
142
142
}
143
143
144
- keyID := ""
145
144
var proxyTargetBytes int
146
145
var targetConn * natconn
147
146
@@ -169,7 +168,7 @@ func (h *packetHandler) Handle(clientConn net.PacketConn) {
169
168
var textData []byte
170
169
var cryptoKey * shadowsocks.EncryptionKey
171
170
unpackStart := time .Now ()
172
- textData , keyID , cryptoKey , err = findAccessKeyUDP (ip , textBuf , cipherData , h .ciphers , h .logger )
171
+ textData , keyID , cryptoKey , err : = findAccessKeyUDP (ip , textBuf , cipherData , h .ciphers , h .logger )
173
172
timeToCipher := time .Since (unpackStart )
174
173
h .ssm .AddCipherSearch (err == nil , timeToCipher )
175
174
@@ -197,9 +196,6 @@ func (h *packetHandler) Handle(clientConn net.PacketConn) {
197
196
return onet .NewConnectionError ("ERR_CIPHER" , "Failed to unpack data from client" , err )
198
197
}
199
198
200
- // The key ID is known with confidence once decryption succeeds.
201
- keyID = targetConn .keyID
202
-
203
199
var onetErr * onet.ConnectionError
204
200
if payload , tgtUDPAddr , onetErr = h .validatePacket (textData ); onetErr != nil {
205
201
return onetErr
@@ -254,7 +250,6 @@ func isDNS(addr net.Addr) bool {
254
250
type natconn struct {
255
251
net.PacketConn
256
252
cryptoKey * shadowsocks.EncryptionKey
257
- keyID string
258
253
metrics UDPConnMetrics
259
254
// NAT timeout to apply for non-DNS packets.
260
255
defaultTimeout time.Duration
@@ -333,11 +328,10 @@ func (m *natmap) Get(key string) *natconn {
333
328
return m .keyConn [key ]
334
329
}
335
330
336
- func (m * natmap ) set (key string , pc net.PacketConn , cryptoKey * shadowsocks.EncryptionKey , keyID string , connMetrics UDPConnMetrics ) * natconn {
331
+ func (m * natmap ) set (key string , pc net.PacketConn , cryptoKey * shadowsocks.EncryptionKey , connMetrics UDPConnMetrics ) * natconn {
337
332
entry := & natconn {
338
333
PacketConn : pc ,
339
334
cryptoKey : cryptoKey ,
340
- keyID : keyID ,
341
335
metrics : connMetrics ,
342
336
defaultTimeout : m .timeout ,
343
337
}
@@ -363,10 +357,10 @@ func (m *natmap) del(key string) net.PacketConn {
363
357
364
358
func (m * natmap ) Add (clientAddr net.Addr , clientConn net.PacketConn , cryptoKey * shadowsocks.EncryptionKey , targetConn net.PacketConn , keyID string ) * natconn {
365
359
connMetrics := m .metrics .AddUDPNatEntry (clientAddr , keyID )
366
- entry := m .set (clientAddr .String (), targetConn , cryptoKey , keyID , connMetrics )
360
+ entry := m .set (clientAddr .String (), targetConn , cryptoKey , connMetrics )
367
361
368
362
go func () {
369
- timedCopy (clientAddr , clientConn , entry , keyID , m .logger )
363
+ timedCopy (clientAddr , clientConn , entry , m .logger )
370
364
connMetrics .RemoveNatEntry ()
371
365
if pc := m .del (clientAddr .String ()); pc != nil {
372
366
pc .Close ()
@@ -394,7 +388,7 @@ func (m *natmap) Close() error {
394
388
var maxAddrLen int = len (socks .ParseAddr ("[2001:db8::1]:12345" ))
395
389
396
390
// copy from target to client until read timeout
397
- func timedCopy (clientAddr net.Addr , clientConn net.PacketConn , targetConn * natconn , keyID string , l * slog.Logger ) {
391
+ func timedCopy (clientAddr net.Addr , clientConn net.PacketConn , targetConn * natconn , l * slog.Logger ) {
398
392
// pkt is used for in-place encryption of downstream UDP packets, with the layout
399
393
// [padding?][salt][address][body][tag][extra]
400
394
// Padding is only used if the address is IPv4.
0 commit comments