Skip to content

Commit

Permalink
Fix inconsistent indents in GUIDE.md examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
huin committed Feb 21, 2021
1 parent 86667cb commit e7fc2c5
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ type RouterClient interface {
NewLeaseDuration uint32,
) (err error)

GetExternalIPAddress() (
NewExternalIPAddress string,
err error,
)
GetExternalIPAddress() (
NewExternalIPAddress string,
err error,
)
}

func PickRouterClient(ctx context.Context) (RouterClient, error) {
tasks, _ := errgroup.WithContext(ctx)
// Request each type of client in parallel, and return what is found.
// Request each type of client in parallel, and return what is found.
var ip1Clients []*internetgateway2.WANIPConnection1
tasks.Go(func() error {
var err error
Expand All @@ -73,9 +73,9 @@ func PickRouterClient(ctx context.Context) (RouterClient, error) {
return nil, err
}

// Trivial handling for where we find exactly one device to talk to, you
// might want to provide more flexible handling than this if multiple
// devices are found.
// Trivial handling for where we find exactly one device to talk to, you
// might want to provide more flexible handling than this if multiple
// devices are found.
switch {
case len(ip2Clients) == 1:
return ip2Clients[0], nil
Expand All @@ -94,36 +94,36 @@ external IP address and forward it to a port on your local network, e.g:

```go
func GetIPAndForwardPort(ctx context.Context) error {
client, err := PickRouterClient(ctx)
if err != nil {
return err
}

externalIP, err := client.GetExternalIPAddress()
if err != nil {
return err
}
fmt.Println("Our external IP address is: ", externalIP)

return client.AddPortMapping(
client, err := PickRouterClient(ctx)
if err != nil {
return err
}

externalIP, err := client.GetExternalIPAddress()
if err != nil {
return err
}
fmt.Println("Our external IP address is: ", externalIP)

return client.AddPortMapping(
"",
// External port number to expose to Internet:
// External port number to expose to Internet:
1234,
// Forward TCP (this could be "UDP" if we wanted that instead).
// Forward TCP (this could be "UDP" if we wanted that instead).
"TCP",
// Internal port number on the LAN to forward to.
// Some routers might not support this being different to the external
// port number.
// Internal port number on the LAN to forward to.
// Some routers might not support this being different to the external
// port number.
1234,
// Internal address on the LAN we want to forward to.
// Internal address on the LAN we want to forward to.
"192.168.1.6",
// Enabled:
// Enabled:
true,
// Informational description for the client requesting the port forwarding.
// Informational description for the client requesting the port forwarding.
"MyProgramName",
// How long should the port forward last for in seconds.
// If you want to keep it open for longer and potentially across router
// resets, you might want to periodically request before this elapses.
// How long should the port forward last for in seconds.
// If you want to keep it open for longer and potentially across router
// resets, you might want to periodically request before this elapses.
3600,
)
}
Expand Down

0 comments on commit e7fc2c5

Please sign in to comment.