chore: support old chacha20
This commit is contained in:
parent
994e85425f
commit
2dc62024fe
4 changed files with 30 additions and 4 deletions
5
go.mod
5
go.mod
|
@ -3,6 +3,7 @@ module github.com/Dreamacro/clash
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da
|
||||||
github.com/cilium/ebpf v0.9.3
|
github.com/cilium/ebpf v0.9.3
|
||||||
github.com/coreos/go-iptables v0.6.0
|
github.com/coreos/go-iptables v0.6.0
|
||||||
github.com/database64128/tfo-go/v2 v2.0.2
|
github.com/database64128/tfo-go/v2 v2.0.2
|
||||||
|
@ -24,7 +25,7 @@ require (
|
||||||
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97
|
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97
|
||||||
github.com/sagernet/sing v0.0.0-20221008120626-60a9910eefe4
|
github.com/sagernet/sing v0.0.0-20221008120626-60a9910eefe4
|
||||||
github.com/sagernet/sing-shadowsocks v0.0.0-20221112030934-e55284e180ea
|
github.com/sagernet/sing-shadowsocks v0.0.0-20221112030934-e55284e180ea
|
||||||
github.com/sagernet/sing-tun v0.0.0-20221012082254-488c3b75f6fd
|
github.com/sagernet/sing-tun v0.0.0-20221104121441-66c48a57776f
|
||||||
github.com/sagernet/sing-vmess v0.0.0-20221109021549-b446d5bdddf0
|
github.com/sagernet/sing-vmess v0.0.0-20221109021549-b446d5bdddf0
|
||||||
github.com/sagernet/wireguard-go v0.0.0-20221108054404-7c2acadba17c
|
github.com/sagernet/wireguard-go v0.0.0-20221108054404-7c2acadba17c
|
||||||
github.com/sirupsen/logrus v1.9.0
|
github.com/sirupsen/logrus v1.9.0
|
||||||
|
@ -47,7 +48,7 @@ replace github.com/lucas-clemente/quic-go => github.com/HyNetwork/quic-go v0.30.
|
||||||
|
|
||||||
replace github.com/sagernet/sing-tun => github.com/MetaCubeX/sing-tun v0.0.0-20221105124245-542e9b56a6dc
|
replace github.com/sagernet/sing-tun => github.com/MetaCubeX/sing-tun v0.0.0-20221105124245-542e9b56a6dc
|
||||||
|
|
||||||
replace github.com/sagernet/sing-shadowsocks => github.com/MetaCubeX/sing-shadowsocks v0.0.0-20221115121930-f1357ec9c15e
|
replace github.com/sagernet/sing-shadowsocks => github.com/MetaCubeX/sing-shadowsocks v0.0.0-20221116103607-48a7095182b1
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/ajg/form v1.5.1 // indirect
|
github.com/ajg/form v1.5.1 // indirect
|
||||||
|
|
6
go.sum
6
go.sum
|
@ -1,9 +1,11 @@
|
||||||
github.com/HyNetwork/quic-go v0.30.1-0.20221105180419-83715d7269a8 h1:FBo40lMrk1bZZzJRJx8U+bQUPhLDGTUJ/Q5NV5BbO4Q=
|
github.com/HyNetwork/quic-go v0.30.1-0.20221105180419-83715d7269a8 h1:FBo40lMrk1bZZzJRJx8U+bQUPhLDGTUJ/Q5NV5BbO4Q=
|
||||||
github.com/HyNetwork/quic-go v0.30.1-0.20221105180419-83715d7269a8/go.mod h1:ssOrRsOmdxa768Wr78vnh2B8JozgLsMzG/g+0qEC7uk=
|
github.com/HyNetwork/quic-go v0.30.1-0.20221105180419-83715d7269a8/go.mod h1:ssOrRsOmdxa768Wr78vnh2B8JozgLsMzG/g+0qEC7uk=
|
||||||
github.com/MetaCubeX/sing-shadowsocks v0.0.0-20221115121930-f1357ec9c15e h1:61mKDq9ldYCH3Yb/Pelib+ISIXegprbm1CSPGB+HpT4=
|
github.com/MetaCubeX/sing-shadowsocks v0.0.0-20221116103607-48a7095182b1 h1:guMcwJSIjk+jg/38uMPK5hIWVSaLHJ/l+ABZ8w2CKm0=
|
||||||
github.com/MetaCubeX/sing-shadowsocks v0.0.0-20221115121930-f1357ec9c15e/go.mod h1:16sNARQbsFbYIzAuPySszQA6Wfgzk7GWSzh1a6kDrUU=
|
github.com/MetaCubeX/sing-shadowsocks v0.0.0-20221116103607-48a7095182b1/go.mod h1:3bW+hVWFXOxRC1HL6CO6QHkegqjLohErGbcvt6dUN18=
|
||||||
github.com/MetaCubeX/sing-tun v0.0.0-20221105124245-542e9b56a6dc h1:B1vmR4cwDjJQ6YM8NkuXmt9vIYOdV/+qA+F3UAFE3YY=
|
github.com/MetaCubeX/sing-tun v0.0.0-20221105124245-542e9b56a6dc h1:B1vmR4cwDjJQ6YM8NkuXmt9vIYOdV/+qA+F3UAFE3YY=
|
||||||
github.com/MetaCubeX/sing-tun v0.0.0-20221105124245-542e9b56a6dc/go.mod h1:1u3pjXA9HmH7kRiBJqM3C/zPxrxnCLd3svmqtub/RFU=
|
github.com/MetaCubeX/sing-tun v0.0.0-20221105124245-542e9b56a6dc/go.mod h1:1u3pjXA9HmH7kRiBJqM3C/zPxrxnCLd3svmqtub/RFU=
|
||||||
|
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY=
|
||||||
|
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA=
|
||||||
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
|
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
|
||||||
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
|
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
|
||||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||||
|
|
|
@ -59,6 +59,7 @@ var streamList = map[string]struct {
|
||||||
"AES-128-CFB": {16, shadowstream.AESCFB},
|
"AES-128-CFB": {16, shadowstream.AESCFB},
|
||||||
"AES-192-CFB": {24, shadowstream.AESCFB},
|
"AES-192-CFB": {24, shadowstream.AESCFB},
|
||||||
"AES-256-CFB": {32, shadowstream.AESCFB},
|
"AES-256-CFB": {32, shadowstream.AESCFB},
|
||||||
|
"CHACHA20": {32, shadowstream.ChaCha20},
|
||||||
"CHACHA20-IETF": {32, shadowstream.Chacha20IETF},
|
"CHACHA20-IETF": {32, shadowstream.Chacha20IETF},
|
||||||
"XCHACHA20": {32, shadowstream.Xchacha20},
|
"XCHACHA20": {32, shadowstream.Xchacha20},
|
||||||
}
|
}
|
||||||
|
|
22
transport/shadowsocks/shadowstream/old_chacha20.go
Normal file
22
transport/shadowsocks/shadowstream/old_chacha20.go
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package shadowstream
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/cipher"
|
||||||
|
"github.com/aead/chacha20/chacha"
|
||||||
|
)
|
||||||
|
|
||||||
|
type chacha20key []byte
|
||||||
|
|
||||||
|
func (k chacha20key) IVSize() int {
|
||||||
|
return chacha.NonceSize
|
||||||
|
}
|
||||||
|
func (k chacha20key) Encrypter(iv []byte) cipher.Stream {
|
||||||
|
c, _ := chacha.NewCipher(iv, k, 20)
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
func (k chacha20key) Decrypter(iv []byte) cipher.Stream {
|
||||||
|
return k.Encrypter(iv)
|
||||||
|
}
|
||||||
|
func ChaCha20(key []byte) (Cipher, error) {
|
||||||
|
return chacha20key(key), nil
|
||||||
|
}
|
Loading…
Reference in a new issue