@@ -31,7 +31,7 @@ import (
3131var (
3232 l log.Logger
3333 internals = []string {"id" , "ca_cert" }
34- ValidTypes = []string {"bool" , "int" , "string" , "float" }
34+ ValidTypes = []string {consts . OpTypeBool , consts . OpTypeInt , consts . OpTypeString , consts . OpTypeFloat }
3535 builderConfig * BuilderConfig
3636)
3737
@@ -82,59 +82,60 @@ func defaultOptions() []*builderpb.Option {
8282 Name : "id" ,
8383 Description : "[internal] the agent ID assigned to the build (immutable)" ,
8484 Default : builderConfig .ID ,
85- Type : "string" ,
85+ Type : consts . OpTypeString ,
8686 Required : true ,
8787 }
8888 name := & builderpb.Option {
8989 Name : "name" ,
9090 Description : "name of this particular agent instance" ,
9191 Default : builderConfig .ID ,
92- Type : "string" ,
92+ Type : consts . OpTypeString ,
9393 Required : false ,
9494 }
9595 OS := & builderpb.Option {
9696 Name : "os" ,
9797 Description : "the OS that the build targets" ,
9898 Default : runtime .GOOS ,
99+ Type : consts .OpTypeString ,
99100 Required : false ,
100101 }
101102 arch := & builderpb.Option {
102103 Name : "arch" ,
103104 Description : "the platform architecture that the build targets" ,
104105 Default : "amd64" ,
105- Type : "string" ,
106+ Type : consts . OpTypeString ,
106107 Required : false ,
107108 }
108109 def := config .MainConfig .Interface
109110 if def == "" {
110111 def = config .ClientConfig .RHost
111112 }
112113 host := & builderpb.Option {
113- Name : "host " ,
114+ Name : "lhost " ,
114115 Description : "the host that the agent calls back to" ,
115116 Default : def ,
116- Type : "string" ,
117+ Type : consts . OpTypeString ,
117118 Required : false ,
118119 }
119120 port := & builderpb.Option {
120- Name : "port" ,
121+ Name : consts . OpLPort ,
121122 Description : "the port on which to connect to the host on callback" ,
122- Default : "8000 " ,
123- Type : "int" ,
123+ Default : "" ,
124+ Type : consts . OpTypeInt ,
124125 Required : false ,
125126 }
126127 out := & builderpb.Option {
127128 Name : "outfile" ,
128129 Description : "the name of the resulting binary" ,
129130 Default : "" ,
130- Type : "string" ,
131+ Type : consts . OpTypeString ,
131132 Required : false ,
132133 }
133134 caCert := & builderpb.Option {
134135 Name : "ca_cert" ,
135136 Description : "[internal] the certificate authority used to sign server certificates (immutable)" ,
136137 Default : "***" ,
137- Type : "string" ,
138+ Type : consts . OpTypeString ,
138139 Required : true ,
139140 }
140141 options = append (options , ID , name , OS , arch , host , port , caCert , out )
@@ -221,17 +222,17 @@ func setCmd(name, value string) {
221222
222223func TypeVerify (t , value string ) error {
223224 switch t {
224- case "int" :
225+ case consts . OpTypeInt :
225226 if _ , err := strconv .Atoi (value ); err != nil {
226227 return fmt .Errorf ("not a valid integer" )
227228 }
228229
229- case "bool" :
230+ case consts . OpTypeBool :
230231 if _ , err := strconv .ParseBool (value ); err != nil {
231232 return fmt .Errorf ("not a valid boolean" )
232233 }
233234
234- case "float" :
235+ case consts . OpTypeFloat :
235236 if _ , err := strconv .ParseFloat (value , 64 ); err != nil {
236237 return fmt .Errorf ("not a valid float" )
237238 }
@@ -355,6 +356,8 @@ func build() {
355356 return
356357 }
357358 l .Success ("build complete. saved to %s" , out .Name ())
359+ // regen in case they want the convenience of building agents in succession
360+ builderConfig .ID = agentID ()
358361}
359362
360363// agentID generates an ID for an agent.
@@ -385,11 +388,11 @@ func gatherOptions() string {
385388
386389func allOptions () []string {
387390 var options []string
388- for k := range builderConfig .request . Options {
389- if slices .Contains (internals , k ) {
391+ for _ , k := range builderConfig .options {
392+ if slices .Contains (internals , k . Name ) {
390393 continue
391394 }
392- options = append (options , k )
395+ options = append (options , k . Name )
393396 }
394397 return options
395398}
0 commit comments