get ready for saving the keys
This commit is contained in:
parent
564bf08803
commit
fa15a55bbd
5 changed files with 72 additions and 21 deletions
|
@ -1 +1,48 @@
|
|||
package tunmanager
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
//Option is a Manager option
|
||||
type Option func(*Manager) error
|
||||
|
||||
//SetHost sets the host of the client's SAM bridge
|
||||
func SetHost(s string) func(*Manager) error {
|
||||
return func(c *Manager) error {
|
||||
c.samhost = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetDataDir sets the directory to save per-site keys
|
||||
func SetDataDir(s string) func(*Manager) error {
|
||||
return func(c *Manager) error {
|
||||
c.datadir = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetPort sets the port of the client's SAM bridge
|
||||
func SetPort(v string) func(*Manager) error {
|
||||
return func(c *Manager) error {
|
||||
port, err := strconv.Atoi(v)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Invalid port; non-number.")
|
||||
}
|
||||
if port < 65536 && port > -1 {
|
||||
c.samport = v
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid port.")
|
||||
}
|
||||
}
|
||||
|
||||
//SetSAMOpts sets the SAM options
|
||||
func SetSAMOpts(s string) func(*Manager) error {
|
||||
return func(c *Manager) error {
|
||||
c.samopts = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue