get ready for saving the keys

This commit is contained in:
idk 2018-12-25 01:45:42 -05:00
parent 564bf08803
commit fa15a55bbd
No known key found for this signature in database
GPG key ID: D75C03B39B5E14E1
5 changed files with 72 additions and 21 deletions

View file

@ -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
}
}