Created
January 31, 2015 20:30
-
-
Save davidgrenier/1e4b8bae110235734959 to your computer and use it in GitHub Desktop.
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
open System.Net | |
open System.Diagnostics | |
let netsh arguments = | |
ProcessStartInfo("netsh", arguments, WindowStyle = ProcessWindowStyle.Hidden) | |
|> Process.Start | |
let rec loop source dest = | |
async { | |
use _ = netsh "interface portproxy reset" | |
use _ = netsh (sprintf "interface portproxy add v4tov4 22 %s 22 %s" dest source) | |
try | |
use cli = new Sockets.TcpClient() | |
do! cli.ConnectAsync(source, 22).ContinueWith ignore | |
|> Async.AwaitTask | |
return 0 | |
with _ -> | |
return! loop source dest | |
} | |
[<EntryPoint>] | |
let main _ = | |
loop "192.168.0.107" "192.168.1.100" | |
|> Async.RunSynchronously |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment