-
Notifications
You must be signed in to change notification settings - Fork 2
/
manager-options.go
136 lines (120 loc) · 3.26 KB
/
manager-options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package sammanager
import (
"fmt"
"strconv"
)
import "github.com/eyedeekay/sam-forwarder/config"
//ManagerOption is a SAMManager Option
type ManagerOption func(*SAMManager) error
//SetManagerFilePath sets the host of the SAMManager's SAM bridge
func SetManagerFilePath(s string) func(*SAMManager) error {
return func(c *SAMManager) error {
c.config.FilePath = s
return nil
}
}
//SetManagerHost sets the host of the SAMManager's SAM bridge
func SetManagerHost(s string) func(*SAMManager) error {
return func(c *SAMManager) error {
c.ServerHost = s
return nil
}
}
//SetManagerWebUser sets the host of the SAMManager's SAM bridge
func SetManagerWebUser(s string) func(*SAMManager) error {
return func(c *SAMManager) error {
c.config.UserName = s
return nil
}
}
//SetManagerWebPass sets the host of the SAMManager's SAM bridge
func SetManagerWebPass(s string) func(*SAMManager) error {
return func(c *SAMManager) error {
c.config.Password = s
return nil
}
}
//SetManagerPort sets the port of the SAMManager's SAM bridge using a string
func SetManagerPort(s string) func(*SAMManager) error {
return func(c *SAMManager) error {
port, err := strconv.Atoi(s)
if err != nil {
return fmt.Errorf("Invalid Manager Server Port %s; non-number ", s)
}
if port < 65536 && port > -1 {
c.ServerPort = s
return nil
}
return fmt.Errorf("Invalid port")
}
}
//SetManagerSAMHost sets the host of the SAMManager's SAM bridge
func SetManagerSAMHost(s string) func(*SAMManager) error {
return func(c *SAMManager) error {
c.SamHost = s
return nil
}
}
//SetManagerSAMPort sets the port of the SAMManager's SAM bridge using a string
func SetManagerSAMPort(s string) func(*SAMManager) error {
return func(c *SAMManager) error {
port, err := strconv.Atoi(s)
if err != nil {
return fmt.Errorf("Invalid Manager SAM Port %s; non-number", s)
}
if port < 65536 && port > -1 {
c.SamPort = s
return nil
}
return fmt.Errorf("Invalid port")
}
}
//SetManagerWebHost sets the host of the SAMManager's SAM bridge
func SetManagerWebHost(s string) func(*SAMManager) error {
return func(c *SAMManager) error {
c.WebHost = s
return nil
}
}
//SetManagerWebPort sets the port of the SAMManager's SAM bridge using a string
func SetManagerWebPort(s string) func(*SAMManager) error {
return func(c *SAMManager) error {
port, err := strconv.Atoi(s)
if err != nil {
return fmt.Errorf("Invalid Manager SAM Port %s; non-number", s)
}
if port < 65536 && port > -1 {
c.WebPort = s
return nil
}
return fmt.Errorf("Invalid port")
}
}
//SetManagerConf sets the host of the SAMManager's SAM bridge
func SetManagerConf(s *i2ptunconf.Conf) func(*SAMManager) error {
return func(c *SAMManager) error {
c.config = s
return nil
}
}
//SetManagerStart sets the host of the SAMManager's SAM bridge
func SetManagerStart(s bool) func(*SAMManager) error {
return func(c *SAMManager) error {
c.start = s
return nil
}
}
//SetManagerWeb sets the host of the SAMManager's SAM bridge
func SetManagerWeb(s bool) func(*SAMManager) error {
return func(c *SAMManager) error {
c.UseWeb = s
return nil
}
}
//SetTunName sets the host of the SAMManager's SAM bridge
func SetTunName(s string) func(*SAMManager) error {
return func(c *SAMManager) error {
c.tunName = s
return nil
}
}