增加防探测功能,增加流量加密功能
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/spf13/cobra"
|
||||
"shadowTLS/shadow"
|
||||
)
|
||||
@ -17,6 +18,10 @@ var (
|
||||
Use: "client",
|
||||
Short: "Client mode",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if !verifyAndParseEncryptionKey() {
|
||||
fmt.Println("[Client] Invalid encryption key length")
|
||||
return
|
||||
}
|
||||
client := shadow.NewClient(clientParams.ListenAddr, clientParams.ServerAddr, clientParams.SNI)
|
||||
client.Start()
|
||||
},
|
||||
|
11
cmd/root.go
11
cmd/root.go
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
"shadowTLS/shadow"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -15,6 +16,8 @@ var (
|
||||
|
||||
func init() {
|
||||
rootCmd.CompletionOptions.DisableDefaultCmd = true
|
||||
rootCmd.PersistentFlags().StringVarP(&shadow.HandshakePassword, "password", "p", "", "Password for probe resist.Probe resist will be disabled if password is empty.")
|
||||
rootCmd.PersistentFlags().StringVarP(&shadow.Key, "key", "k", "", "Encryption key for AES-CBC.Encryption will be enabled if key is set.Length of key must be 16,24 or 32.")
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
@ -23,3 +26,11 @@ func Execute() {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func verifyAndParseEncryptionKey() bool {
|
||||
if shadow.Key != "" && len(shadow.Key) != 16 && len(shadow.Key) != 24 && len(shadow.Key) != 32 {
|
||||
return false
|
||||
}
|
||||
shadow.EncryptKey = []byte(shadow.Key)
|
||||
return true
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/spf13/cobra"
|
||||
"shadowTLS/shadow"
|
||||
)
|
||||
@ -17,6 +18,10 @@ var (
|
||||
Use: "server",
|
||||
Short: "Server mode",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if !verifyAndParseEncryptionKey() {
|
||||
fmt.Println("[Server] Invalid encryption key length")
|
||||
return
|
||||
}
|
||||
server := shadow.NewServer(serverParams.ListenAddr, serverParams.TargetAddr, serverParams.FakeAddr)
|
||||
server.Start()
|
||||
},
|
||||
|
Reference in New Issue
Block a user