diff --git a/cmd/vtun.go b/cmd/vtun.go index e4bd452..740f7c7 100644 --- a/cmd/vtun.go +++ b/cmd/vtun.go @@ -8,7 +8,7 @@ import ( "os/exec" "runtime" - "github.com/net-byte/vtun/util" + "github.com/net-byte/vtun/common/cipher" "github.com/songgao/water" ) @@ -24,7 +24,7 @@ func New(local *string, remote *string, port *int, key *string) { log.Fatal("Only support linux!") return } - hashKey := util.CreateHash(*key) + hashKey := cipher.CreateHash(*key) // create tun config := water.Config{ DeviceType: water.TAP, @@ -64,7 +64,7 @@ func New(local *string, remote *string, port *int, key *string) { } b := buf[:n] // decrypt data - util.Decrypt(&b, hashKey) + cipher.Decrypt(&b, hashKey) iface.Write(b) } }() @@ -77,7 +77,7 @@ func New(local *string, remote *string, port *int, key *string) { } b := packet[:n] // encrypt data - util.Encrypt(&b, hashKey) + cipher.Encrypt(&b, hashKey) conn.WriteToUDP(b, remoteAddr) } } @@ -95,6 +95,6 @@ func execCmd(c string, args ...string) { cmd.Stdin = os.Stdin err := cmd.Run() if nil != err { - log.Fatalln("Error running /sbin/ip:", err) + log.Fatalln("Exec /sbin/ip error:", err) } } diff --git a/util/cipher.go b/common/cipher/cipher.go similarity index 97% rename from util/cipher.go rename to common/cipher/cipher.go index 077e276..80f719e 100644 --- a/util/cipher.go +++ b/common/cipher/cipher.go @@ -1,4 +1,4 @@ -package util +package cipher import ( "crypto/sha256" diff --git a/go.mod b/go.mod index 65d7371..7b2ea45 100644 --- a/go.mod +++ b/go.mod @@ -5,5 +5,4 @@ go 1.16 require ( github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 - golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 )