init
This commit is contained in:
35
cmd/client.go
Normal file
35
cmd/client.go
Normal file
@ -0,0 +1,35 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"shadowTLS/shadow"
|
||||
)
|
||||
|
||||
type ClientParam struct {
|
||||
ListenAddr string
|
||||
ServerAddr string
|
||||
SNI string
|
||||
}
|
||||
|
||||
var (
|
||||
clientParams *ClientParam
|
||||
clientCmd = &cobra.Command{
|
||||
Use: "client",
|
||||
Short: "Client mode",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
client := shadow.NewClient(clientParams.ListenAddr, clientParams.ServerAddr, clientParams.SNI)
|
||||
client.Start()
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
clientParams = &ClientParam{}
|
||||
clientCmd.Flags().StringVarP(&clientParams.ListenAddr, "listen", "l", "0.0.0.0:18080", "Listen address and port")
|
||||
clientCmd.Flags().StringVarP(&clientParams.ServerAddr, "saddr", "s", "", "Server address and port")
|
||||
clientCmd.Flags().StringVarP(&clientParams.SNI, "domain", "d", "", "Domain name used for TLS Handshake")
|
||||
clientCmd.MarkFlagRequired("listen")
|
||||
clientCmd.MarkFlagRequired("saddr")
|
||||
clientCmd.MarkFlagRequired("sni")
|
||||
rootCmd.AddCommand(clientCmd)
|
||||
}
|
Reference in New Issue
Block a user