-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52998a7
commit 5628fa6
Showing
7 changed files
with
275 additions
and
20 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,45 @@ | ||
package mobile | ||
|
||
import ( | ||
"github.com/mythologyli/zju-connect/client" | ||
"github.com/mythologyli/zju-connect/log" | ||
"github.com/mythologyli/zju-connect/stack/tun" | ||
) | ||
|
||
var vpnClient *client.EasyConnectClient | ||
|
||
func Login(server string, username string, password string) string { | ||
log.Init() | ||
|
||
vpnClient = client.NewEasyConnectClient( | ||
server, | ||
username, | ||
password, | ||
"", | ||
false, | ||
false, | ||
) | ||
err := vpnClient.Setup() | ||
if err != nil { | ||
return "" | ||
} | ||
|
||
log.Printf("EasyConnect client started") | ||
|
||
clientIP, err := vpnClient.IP() | ||
if err != nil { | ||
return "" | ||
} | ||
|
||
return clientIP.String() | ||
} | ||
|
||
func StartStack(fd int) { | ||
vpnTUNStack, err := tun.NewStack(vpnClient, "") | ||
if err != nil { | ||
return | ||
} | ||
|
||
vpnTUNStack.SetupTun(fd) | ||
vpnTUNStack.Run() | ||
} |
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
Oops, something went wrong.