heron
2017-08-18 9342133639373a2d4fc2190568a644796db73c97
shell 수정
3 files modified
155 ■■■■ changed files
README.MD 14 ●●●●● patch | view | raw | blame | history
src/accessmotion.my/main/ipes.go 6 ●●●●● patch | view | raw | blame | history
src/accessmotion.my/shell/shell.go 135 ●●●● patch | view | raw | blame | history
README.MD
....@@ -3,11 +3,15 @@
33
44 C:\Work\Access-Motion\Analytics\src\recevieWebLog>set GOOS=linux
55 C:\Work\Access-Motion\Analytics\src\recevieWebLog>set GOARCH=amd64
6
-C:\Work\Access-Motion\Analytics\src\recevieWebLog>go build -v recevieWebLog.go
7
-
8
-
6
+C:\Work\Access-Motion\Analytics\src\recevieWebLog>go build -v ipes.go
97
108 set GOPATH=C:\Work\Access-Motion\PROB\src\IPES_CLI
119
12
-spring.main.web-environment=false
13
-spring.main.banner-mode=off
10
+
11
+
12
+
13
+
14
+
15
+root# sudo vi /etc/shells -> /bin/ipes 추가
16
+pbsvr# chsh -s /bin/ipes
17
+ipes# chsh -s /bin/ipes
src/accessmotion.my/main/ipes.go
....@@ -1,11 +1,13 @@
11 package main
22
33 import (
4
- ipes "accessmotion.my/cmd"
4
+ //ipes "accessmotion.my/cmd"
5
+ ipesShell "accessmotion.my/shell"
56 )
67
78 func main() {
8
- ipes.Execute()
9
+ //ipes.Execute()
10
+ ipesShell.Shell()
911 }
1012
1113
src/accessmotion.my/shell/shell.go
....@@ -50,12 +50,24 @@
5050 readline.PcItem("debug",
5151 readline.PcItem("session"),
5252 readline.PcItem("injection"),
53
- readline.PcItem("on"),
53
+ readline.PcItem("on",
54
+ readline.PcItem("SYS"),
55
+ readline.PcItem("LOG"),
56
+ readline.PcItem("ERR"),
57
+ readline.PcItem("DOMAINS"),
58
+ readline.PcItem("SESSION"),
59
+ readline.PcItem("URIPATH"),
60
+ readline.PcItem("AAA"),
61
+ readline.PcItem("HTMLOUT"),
62
+ readline.PcItem("AGNTCHK"),
63
+ readline.PcItem("TELCO"),
64
+ readline.PcItem("SSL"),
65
+ readline.PcItem("ALL"),
66
+ ),
5467 readline.PcItem("off"),
5568 ),
5669 readline.PcItem("url"),
5770 ),
58
-
5971 readline.PcItem("exit"),
6072 )
6173
....@@ -67,7 +79,6 @@
6779 }
6880 return r, true
6981 }
70
-
7182
7283
7384 func Shell() {
....@@ -109,9 +120,7 @@
109120 line = strings.TrimSpace(line)
110121
111122 switch {
112
- case strings.HasPrefix(line, "logTransfer"):
113
- logTransfer(strings.TrimSpace(line[11:]))
114
- break
123
+
115124 case strings.HasPrefix(line, "dlswjfal"):
116125 _, err := l.ReadPassword("please enter your password: ")
117126 if err != nil {
....@@ -157,17 +166,13 @@
157166 }
158167 switch {
159168 case strings.HasPrefix(line, "debug"):
160
- line = strings.TrimSpace(line[5:])
161
- switch {
162
- case strings.HasPrefix(line, "on"):
163
- break
164
- case strings.HasPrefix(line, "off"):
165
- break
166
- case strings.HasPrefix(line, "session"):
167
- break
168
- case strings.HasPrefix(line, "injection"):
169
+ line := strings.TrimSpace(line[5:])
170
+ if len(line) == 0 {
171
+ usage(l.Stderr())
169172 break
170173 }
174
+ setDebug(l,line)
175
+ break
171176 case strings.HasPrefix(line, "injection"):
172177 injection(strings.TrimSpace(line[9:]))
173178 break
....@@ -179,6 +184,22 @@
179184 break
180185 }
181186 whois(strings.TrimSpace(line))
187
+ break
188
+ case strings.HasPrefix(line, "logTransfer"):
189
+ line := strings.TrimSpace(line[11:])
190
+ if len(line) == 0 {
191
+ usage(l.Stderr())
192
+ break
193
+ }
194
+ logTransfer(line)
195
+ break
196
+ case strings.HasPrefix(line, "url"):
197
+ line := strings.TrimSpace(line[3:])
198
+ if len(line) == 0 {
199
+ usage(l.Stderr())
200
+ break
201
+ }
202
+ setUrl(line)
182203 break
183204 case line == "help":
184205 usage(l.Stderr())
....@@ -192,7 +213,6 @@
192213 }
193214 exit:
194215 }
195
-
196216
197217 func showInjectionStatus(){
198218 out, err := exec.Command("cat","/proc/ipswitch/configs").Output()
....@@ -293,10 +313,6 @@
293313 }
294314 }
295315
296
-
297
-
298
-
299
-
300316 func setConfig(configName string,valueType string, value string){
301317 cmdName := "echo"
302318 input :=strings.TrimSpace(value)
....@@ -311,12 +327,17 @@
311327 fmt.Printf("err %s", err)
312328 }
313329 //log.Printf("%s\n",out)
314
- getConfig(configName)
330
+ out := getConfig(configName)
331
+
332
+ log.Printf("value %s\n",out)
315333
316334 }
317335 }
318336
319
-func getConfig(configName string){
337
+func getConfig(configName string) string{
338
+
339
+ var result string
340
+
320341 out, err := exec.Command("cat","/proc/ipswitch/configs").Output()
321342 if err != nil {
322343 log.Printf("err %s", err)
....@@ -331,15 +352,17 @@
331352 if strconv.Itoa(desc) == string(output[1]){
332353 /*log.Printf("value: %s -- %d \n",
333354 strings.TrimSpace(string(output[3])),desc)*/
334
- log.Printf("set value: %s \n", strings.TrimSpace(string(output[3])))
355
+ //log.Printf("set value: %s \n", strings.TrimSpace(string(output[3])))
356
+ result = strings.TrimSpace(string(output[3]))
335357 }else{
358
+
336359 }
337360 }
338361 i = i + 1
339362 }
363
+
364
+ return result
340365 }
341
-
342
-
343366
344367 func logTransfer(line string){
345368 switch {
....@@ -365,14 +388,68 @@
365388 }
366389 }
367390
368
-func setDebug(){
391
+func setDebug(l *readline.Instance, line string){
392
+ switch {
393
+ case strings.HasPrefix(line, "on"):
394
+ line := strings.TrimSpace(line[2:])
395
+ if len(line) == 0 {
396
+ usage(l.Stderr())
397
+ break
398
+ }
399
+ desc, prs := debugNames["DEBUG_"+line]
400
+ if prs == false{
401
+ }else {
402
+ value := getConfig("debug_state")
403
+ valueToint,_ := strconv.Atoi(value)
404
+ valueToint = valueToint + desc
405
+ setConfig("debug_state","0",strconv.Itoa(valueToint))
406
+ }
407
+ break
408
+ case strings.HasPrefix(line, "off"):
409
+ desc, prs := debugNames["DEBUG_OFF"]
410
+ if prs == false{
411
+ }else {
412
+ setConfig("debug_state","0",strconv.Itoa(desc))
413
+ }
414
+ break
415
+ case strings.HasPrefix(line, "session"):
416
+ desc, prs := debugNames["DEBUG_SESSION"]
417
+ if prs == false{
418
+ }else {
419
+ setConfig("debug_state","0",strconv.Itoa(desc))
420
+ }
369421
422
+ break
423
+ case strings.HasPrefix(line, "injection"):
424
+ desc, prs := debugNames["DEBUG_HTMLOUT"]
425
+ if prs == false{
426
+ }else {
427
+ setConfig("debug_state","0",strconv.Itoa(desc))
428
+ }
429
+ break
430
+ }
431
+}
432
+
433
+func setUrl(line string){
434
+ setConfig("parental_control_url","1",line)
370435 }
371436
372437
373
-
374
-
375
-
438
+var debugNames = map[string]int{
439
+ "DEBUG_OFF":0,
440
+ "DEBUG_SYS":1,
441
+ "DEBUG_LOG":2,
442
+ "DEBUG_ERR":4,
443
+ "DEBUG_DOMAINS":8,
444
+ "DEBUG_SESSION":16,
445
+ "DEBUG_URIPATH":32,
446
+ "DEBUG_AAA":64,
447
+ "DEBUG_HTMLOUT":128,
448
+ "DEBUG_AGNTCHK":256,
449
+ "DEBUG_TELCO":512,
450
+ "DEBUG_SSL":1024,
451
+ "DEBUG_ALL":2047,
452
+}
376453
377454
378455 var configNames = map[string]int{