Skip to content

Commit

Permalink
Support access UNIX-DOMAIN socket server application
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffyjf authored and kungze-robot committed Apr 29, 2022
1 parent 75480fe commit 128155e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Start up server side endpoint
Start up client side endpoint

```
./quictun-client --listen-on tcp:127.0.0.1:6500 --server-endpoint 172.18.31.36:7500 --token 172.18.30.117:22 --insecure-skip-verify True
./quictun-client --listen-on tcp:127.0.0.1:6500 --server-endpoint 172.18.31.36:7500 --token tcp:172.18.30.117:22 --insecure-skip-verify True
```

**Note:** The value specified by `--token` used to tell `quictun-server` the application address that the client want to access.
Expand Down
2 changes: 1 addition & 1 deletion client/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func main() {
defer klog.Flush()
rootCmd.PersistentFlags().StringVar(&localSocket, "listen-on", "tcp:127.0.0.1:6500", "The socket that the client side endpoint listen on.")
rootCmd.PersistentFlags().StringVar(&serverEndpointSocket, "server-endpoint", "", "The server side endpoint address, example: example.com:6565")
rootCmd.PersistentFlags().StringVar(&token, "token", "", "Used to tell the server endpoint which server app we want to connect.")
rootCmd.PersistentFlags().StringVar(&token, "token", "", "Used to tell the server endpoint which server app we want to connect, example: tcp:10.0.0.1:1234")
rootCmd.PersistentFlags().StringVar(&certFile, "cert-file", "", "The certificate file path, this is required if the --verify-client is True in server endpoint.")
rootCmd.PersistentFlags().StringVar(&keyFile, "key-file", "", "The private key file path, this is required if the --verify-client is True in server endpoint.")
rootCmd.PersistentFlags().BoolVar(&insecureSkipVerify, "insecure-skip-verify", false, "Whether skip verify server endpoint.")
Expand Down
4 changes: 3 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/tls"
"io"
"net"
"strings"
"sync"

"github.com/kungze/quic-tun/pkg/constants"
Expand Down Expand Up @@ -70,7 +71,8 @@ func (s *ServerEndpoint) handshake(stream *quic.Stream) (net.Conn, error) {
return nil, err
}
klog.InfoS("starting connect to server app", "server app", hsh.ReceiveData)
conn, err := net.Dial("tcp", hsh.ReceiveData)
sockets := strings.Split(hsh.ReceiveData, ":")
conn, err := net.Dial(strings.ToLower(sockets[0]), strings.Join(sockets[1:], ":"))
if err != nil {
klog.ErrorS(err, "Failed to dial server app", "server address", hsh.ReceiveData)
hsh.SendData = []byte{constants.HandshakeFailure}
Expand Down

0 comments on commit 128155e

Please sign in to comment.