-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: refactor client and server
- Loading branch information
Showing
6 changed files
with
68 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"net" | ||
|
||
"tunelo/pkg/logger" | ||
) | ||
|
||
type tcpTransport struct { | ||
vpnConn *net.UDPConn | ||
log logger.Logger | ||
} | ||
|
||
func (t *tcpTransport) handle(conn net.Conn) { | ||
defer conn.Close() | ||
|
||
go func() { | ||
if _, err := io.Copy(t.vpnConn, conn); err != nil { | ||
t.log.Error(fmt.Errorf("copying from tcp conn to vpn: %v", err), nil) | ||
} | ||
}() | ||
|
||
if _, err := io.Copy(conn, t.vpnConn); err != nil { | ||
t.log.Error(fmt.Errorf("copying from vpn to tcp conn: %v", err), nil) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"net" | ||
|
||
"tunelo/pkg/logger" | ||
) | ||
|
||
type utlsTransport struct { | ||
vpnConn *net.UDPConn | ||
log logger.Logger | ||
} | ||
|
||
func (t *utlsTransport) handle(conn net.Conn) { | ||
defer conn.Close() | ||
|
||
go func() { | ||
if _, err := io.Copy(t.vpnConn, conn); err != nil { | ||
t.log.Error(fmt.Errorf("copying from tls conn to vpn: %v", err), nil) | ||
} | ||
}() | ||
|
||
if _, err := io.Copy(conn, t.vpnConn); err != nil { | ||
t.log.Error(fmt.Errorf("copying from vpn to tls conn: %v", err), nil) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters