Skip to content

Commit

Permalink
resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-henderson-ty committed Dec 9, 2019
2 parents 308ea9b + 3e9b28f commit 047f2d2
Show file tree
Hide file tree
Showing 24 changed files with 808 additions and 220 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@
- run relay server `server -SelfTKey [relay server's TKey]`
- run exit server `server -SelfTKey [exit server's TKey] -UseRelay -RelayServerIp [relay server's IP] -RelayServerTKey [relay server's TKey]`
- run client `client -IsRelay -ServerIp [relay server's IP] -ServerTKey [relay server's TKey] -ExitServerClientId [exit server's ClientId] -ExitServerToken [exit server's TKey]`


This product includes GeoLite2 data created by MaxMind, available from
<a href="https://www.maxmind.com">https://www.maxmind.com</a>.
2 changes: 1 addition & 1 deletion src/github.com/tachyon-protocol/udw
Submodule udw updated 40 files
+4 −1 README.md
+160 −0 udwBufio/BufioReader.go
+125 −0 udwBufio/BufioReader_test.go
+72 −0 udwBufio/BufioWriter.go
+32 −0 udwBufio/BufioWriter_test.go
+24 −0 udwBytes/BufWriter_test.go
+31 −36 udwConsole/Completion.go
+5 −3 udwConsole/udwConsole.go
+5 −0 udwCryptoSha3/udwSha3512.go
+524 −0 udwIpToCountryV2/getGeoip2Reader.go
+107 −0 udwIpToCountryV2/udwIpCountryV2Map/reader.go
+16 −0 udwIpToCountryV2/udwIpCountryV2Map/reader_amd64.go
+10 −0 udwIpToCountryV2/udwIpCountryV2Map/reader_other.go
+51 −0 udwIpToCountryV2/udwIpToCountry.go
+43 −0 udwIpToCountryV2/udwIpToCountry_test.go
+2 −1 udwNet/error.go
+0 −1 udwNet/route_darwin.go
+47 −18 udwNet/udwIPNet/Ipv4NetSet.go
+1 −1 udwNet/udwIPNet/ipv4NetSet_test.go
+26 −0 udwNet/udwNetTestV2/RunTestOnPipe.go
+174 −0 udwRpc2/client.go
+42 −0 udwRpc2/main.go
+5 −0 udwRpc2/model.go
+67 −0 udwRpc2/rpcError.go
+63 −0 udwRpc2/server.go
+238 −0 udwRpc2/udwRpc2Builder/genRpc.go
+106 −0 udwRpc2/udwRpc2Builder/rpc.go
+150 −0 udwRpc2/udwRpc2Tester/main.go
+46 −0 udwRpc2/udwRpc2Tester/udwRpc2Demo/main.go
+84 −0 udwRpc2/udwRpc2Tester/udwRpc2Demo/runTest.go
+16 −0 udwShm/fuzz_test.go
+360 −0 udwShm/readValue.go
+32 −0 udwShm/read_write_test.go
+49 −0 udwShm/udwShmFuzzLib/fuzz.go
+176 −0 udwShm/udwShmTest/main.go
+126 −0 udwShm/udwShmTest/runTest.go
+243 −0 udwShm/writeValue.go
+11 −0 udwSqlite3/0delete.go
+1 −1 udwSqlite3/flags.go
+7 −3 udwSsh/ssh.go
9 changes: 5 additions & 4 deletions src/make/ci/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ import (
func main(){
tryGoInstall("make/client")
tryGoInstall("make/server")
tryGoInstall("tachyonVpnRouteServer")
thisPath:=udwFile.MustGetFullPath("src/github.com/tachyon-protocol/udw")
dirSet:=map[string]struct{}{}
for _,fullpath:=range udwFile.MustGetAllFiles(thisPath){
if strings.Contains(fullpath,"/.git"){
for _, fullPath :=range udwFile.MustGetAllFiles(thisPath){
if strings.Contains(fullPath,"/.git"){
continue
}
ext:=udwFile.GetExt(fullpath)
ext:=udwFile.GetExt(fullPath)
if ext!=".go"{
continue
}
dirSet[filepath.Dir(fullpath)] = struct{}{}
dirSet[filepath.Dir(fullPath)] = struct{}{}
}
for fullpath:=range dirSet{
rel:=udwFile.MustGetRelativePath(thisPath,fullpath)
Expand Down
10 changes: 10 additions & 0 deletions src/make/routeServer/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package main

import (
"github.com/tachyon-protocol/udw/udwConsole"
"tachyonVpnRouteServer"
)

func main(){
udwConsole.MustRunCommandLineFromFuncV2(tachyonVpnRouteServer.RouteServerRunCmd)
}
17 changes: 15 additions & 2 deletions src/make/sshDeploy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func main() {
Ip string
PkgPath string
Command string
ClientKeyFilePath string
}) {
const (
_os = `linux`
Expand All @@ -26,8 +27,20 @@ func main() {
})
pkgName := filepath.Base(req.PkgPath)
fmt.Println("build successfully", pkgName, _os, "/", arch)
udwSsh.MustScpToRemoteDefault(req.Ip, resp.GetOutputExeFilePath(), "/tmp/"+pkgName)

udwSsh.MustScpToRemote(&udwSsh.RemoteServer{
Ip: req.Ip,
LocalPath: resp.GetOutputExeFilePath(),
RemotePath: "/tmp/"+pkgName,
IsScp: true,
ClientKeyFilePath: req.ClientKeyFilePath,
})
//udwSsh.MustScpToRemoteDefault(req.Ip, resp.GetOutputExeFilePath(), "/tmp/"+pkgName)
//udwSsh.MustRpcSshDefault(serverIp, "mv /tmp/"+pkgName+" /usr/local/bin/"+pkgName+";killall "+pkgName+";setsid "+pkgName+" >> /tmp/server.log 2>&1")
udwSsh.MustRpcSshDefault(req.Ip, "mv /tmp/"+pkgName+" /usr/local/bin/"+pkgName+";killall "+pkgName+";"+req.Command)
udwSsh.MustRpcSsh(udwSsh.RemoteServer{
Ip: req.Ip,
ClientKeyFilePath: req.ClientKeyFilePath,
},"mv /tmp/"+pkgName+" /usr/local/bin/"+pkgName+";killall "+pkgName+";"+req.Command)
//udwSsh.MustRpcSshDefault(req.Ip, "mv /tmp/"+pkgName+" /usr/local/bin/"+pkgName+";killall "+pkgName+";sleep 2;"+req.Command)
})
}
24 changes: 24 additions & 0 deletions src/make/tmp/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package main

import (
"tachyonVpnRouteServer/tachyonVpnRouteClient"
"tachyonVpnProtocol"
"github.com/tachyon-protocol/udw/udwDebug"
"fmt"
)

func main(){
//udwRpc2Tester.BuildAndTest()
routeC:=tachyonVpnRouteClient.Rpc_NewClient(tachyonVpnProtocol.PublicRouteServerAddr)
fmt.Println("start 1")
rpcErr:=routeC.Ping()
if rpcErr!=nil{
panic(rpcErr.Error())
}
fmt.Println("start 2")
list,rpcErr:=routeC.VpnNodeList()
if rpcErr!=nil{
panic(rpcErr.Error())
}
udwDebug.Println(list)
}
133 changes: 101 additions & 32 deletions src/make/tmp/tmpTls/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,43 @@ import (
"crypto/tls"
"tyTls"
"fmt"
"sync"
"github.com/tachyon-protocol/udw/udwErr"
"github.com/tachyon-protocol/udw/udwTest"
"github.com/tachyon-protocol/udw/udwNet/udwNetTestV2"
"net"
"crypto/x509"
"github.com/tachyon-protocol/udw/udwBytes"
"github.com/tachyon-protocol/udw/udwCryptoSha3"
"encoding/base64"
"encoding/pem"
"bytes"
)

type ClientToken struct{
ServerChk string
ClientCert string
}

func main(){
tyTls.EnableTlsVersion13()
certS :=newCert(false)
{
cert_1:=NewTlsCert(false,"27cz7epj6m")
s_1,errMsg:=CertMarshal(&cert_1)
udwErr.PanicIfErrorMsg(errMsg)
cert_2:=NewTlsCert(false,"27cz7epj6m")
s_2,errMsg:=CertMarshal(&cert_2)
udwErr.PanicIfErrorMsg(errMsg)
fmt.Println(s_1==s_2)
}
certS :=tyTls.NewTlsCert(false)
ServerChk :=tyTls.HashChk(certS.Certificate[0])
fmt.Println("ServerChk",ServerChk)
certC:=newCert(true)
s,errMsg:=CertMarshal(&certS)
udwErr.PanicIfErrorMsg(errMsg)
fmt.Println("ServerCert",s,len(s))
certS_1,errMsg:=CertUnmarshal(s)
udwErr.PanicIfErrorMsg(errMsg)
certS=*certS_1

fmt.Println("ServerChk",ServerChk,len(ServerChk))
certC:=tyTls.NewTlsCert(true)
ClientChk :=tyTls.HashChk(certC.Certificate[0])
fmt.Println("ClientChk",ClientChk)
{
Expand All @@ -34,33 +58,78 @@ func main(){
c1,c2:=udwNetTestV2.MustTcpPipe()
tlsC:=tls.Client(c1,cc)
tlsS:=tls.Server(c2,sc)
TestTwoNetConn(tlsC,tlsS)
udwNetTestV2.RunTestTwoRwc(tlsC,tlsS)
}
}

func CertMarshal(cert *tls.Certificate) (s string,errMsg string){
buf:=udwBytes.BufWriter{}
pkB,err:=x509.MarshalPKCS8PrivateKey(cert.PrivateKey)
if err!=nil{
return "",err.Error()
}
buf.WriteUvarint(uint64(len(pkB)))
buf.Write_(pkB)
buf.WriteUvarint(uint64(len(cert.Certificate)))
for _, certRaw:=range cert.Certificate{
buf.WriteUvarint(uint64(len(certRaw)))
buf.Write_(certRaw)
}
sum:=udwCryptoSha3.Sum512Slice(buf.GetBytes())
buf.Write_(sum[:4])
return base64.RawURLEncoding.EncodeToString(buf.GetBytes()),""
}

func TestTwoNetConn(tlsC net.Conn,tlsS net.Conn){
wg:=sync.WaitGroup{}
wg.Add(1)
go func(){
buf:=make([]byte,4096)
nr,err:=tlsS.Read(buf)
fmt.Println("5")
udwErr.PanicIfError(err)
udwTest.Equal(buf[:nr],[]byte{1})
wg.Done()
}()
_,err:=tlsC.Write([]byte{1})
udwErr.PanicIfError(err)
fmt.Println("3")
wg.Wait()
for i:=0;i<10;i++{
_,err:=tlsC.Write([]byte{1})
udwErr.PanicIfError(err)
buf:=make([]byte,4096)
nr,err:=tlsS.Read(buf)
udwErr.PanicIfError(err)
udwTest.Equal(buf[:nr],[]byte{1})
func CertUnmarshal(s string) (tlsCert *tls.Certificate,errMsg string){
b,err:=base64.RawURLEncoding.DecodeString(s)
if err!=nil{
return nil,err.Error()
}
reader:=udwBytes.NewBufReader(b)
pkSize,ok:=reader.ReadUvarint()
if !ok|| pkSize<=1{
return nil,"gmfp28u374"
}
pkB,ok:=reader.ReadByteSlice(int(pkSize))
if !ok{
return nil,"nkt4xh9mfe"
}
pkPem:=pem.EncodeToMemory(&pem.Block{
Type: "PRIVATE KEY",
Bytes: pkB,
})
certListLen,ok:=reader.ReadUvarint()
if !ok{
return nil,"yetwm28kyj"
}
certBuf:=udwBytes.BufWriter{}
for i:=0;i<int(certListLen);i++{
thisCertLen,ok:=reader.ReadUvarint()
if !ok{
return nil,"bbemaktzw4"
}
certB,ok:=reader.ReadByteSlice(int(thisCertLen))
if !ok{
return nil,"m9y5us7quv"
}
certBuf.Write_(pem.EncodeToMemory(&pem.Block{
Type: "CERTIFICATE",
Bytes: certB,
}))
}
tlsC.Close()
tlsS.Close()
}
pos:=reader.GetPos()
shouldSum,ok:=reader.ReadByteSlice(4)
if !ok{
return nil,"h4psrrv3r7"
}
sum:=udwCryptoSha3.Sum512Slice(b[:pos])
if bytes.Equal(sum[:4],shouldSum)==false{
return nil,"kr4xx74xub"
}
tlsCert_1,err:=tls.X509KeyPair(certBuf.GetBytes(),pkPem)
if err!=nil{
return nil,err.Error()
}
return &tlsCert_1,""
}

28 changes: 13 additions & 15 deletions src/make/tmp/tmpTls/newCert.go
Original file line number Diff line number Diff line change
@@ -1,45 +1,43 @@
package main

import (
"time"
"crypto/tls"
"crypto/x509"
"math/big"
"net"
"crypto/ecdsa"
"crypto/elliptic"
"encoding/pem"
"crypto/tls"
"crypto/rand"
"net"
"github.com/tachyon-protocol/udw/udwCryptoSha3"
)

func newCert(isClient bool) (cert tls.Certificate){
func NewTlsCert(isClient bool,randKey string) (cert tls.Certificate){
var ExtKeyUsage x509.ExtKeyUsage
if isClient{
ExtKeyUsage = x509.ExtKeyUsageClientAuth
}else{
ExtKeyUsage = x509.ExtKeyUsageServerAuth
}
const dur = 100*365*24*time.Hour
startTime:=time.Now()
notBefore:=startTime.Add(-dur)
notAfter:=startTime.Add(dur)
hasher:=udwCryptoSha3.NewShake256()
hasher.Write([]byte(randKey))
//notBefore:=startTime.Add(-dur)
//notAfter:=startTime.Add(dur)
template := x509.Certificate{
SerialNumber: big.NewInt(1),
NotBefore: notBefore,
NotAfter: notAfter,
//NotBefore: notBefore,
//NotAfter: notAfter,
KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,
ExtKeyUsage: []x509.ExtKeyUsage{ExtKeyUsage},
BasicConstraintsValid: true,
}
if isClient==false{
template.IPAddresses = []net.IP{net.IPv4(127,0,0,1)}
}
//template.DNSNames = []string{"google.com"}
priv, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
priv, err := ecdsa.GenerateKey(elliptic.P256(), hasher)
if err!=nil{
panic(err)
}
derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv)
derBytes, err := x509.CreateCertificate(hasher, &template, &template, &priv.PublicKey, priv)
if err != nil {
panic(err)
}
Expand All @@ -60,4 +58,4 @@ func newCert(isClient bool) (cert tls.Certificate){
panic(err)
}
return cert
}
}
8 changes: 8 additions & 0 deletions src/make/tpl/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package main

import "github.com/tachyon-protocol/udw/udwBuild"

func main(){
udwBuild.MustBuild()
}

Loading

0 comments on commit 047f2d2

Please sign in to comment.