Fix inconsistent indents in GUIDE.md examples.

This commit is contained in:
John Beisley 2021-02-21 12:36:27 +00:00
parent 86667cb88e
commit e7fc2c5b62
1 changed files with 29 additions and 29 deletions

View File

@ -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
@ -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
@ -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
}
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)
externalIP, err := client.GetExternalIPAddress()
if err != nil {
return err
}
fmt.Println("Our external IP address is: ", externalIP)
return client.AddPortMapping(
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,
)
}