Skip to content

Instantly share code, notes, and snippets.

@davidgrenier
Created January 31, 2015 20:30
Show Gist options
  • Save davidgrenier/1e4b8bae110235734959 to your computer and use it in GitHub Desktop.
Save davidgrenier/1e4b8bae110235734959 to your computer and use it in GitHub Desktop.
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