heron
2017-08-13 1afc934b9de1e940948956fc082401bfe0f439d5
config 수정
2 files modified
83 ■■■■ changed files
src/accessmotion.my/cmd/config.go 70 ●●●●● patch | view | raw | blame | history
src/accessmotion.my/shell/shell.go 13 ●●●●● patch | view | raw | blame | history
src/accessmotion.my/cmd/config.go
....@@ -2,10 +2,42 @@
22
33 import (
44 "github.com/spf13/cobra"
5
+ "os/exec"
6
+ "fmt"
7
+ "strings"
58 )
69
710 func init() {
11
+
12
+ var all = &cobra.Command{
13
+ Use: "all",
14
+ Short: "show all configs",
15
+ Run: func(cmd *cobra.Command, args []string) {
16
+ out, err := exec.Command("cat","/proc/ipswitch/configs").Output()
17
+ if err != nil {
18
+ fmt.Printf("err %s", err)
19
+ }
20
+ var outputs []string = strings.Split(string(out),"\n")
21
+ i:=0
22
+ for i < 61 {
23
+ //fmt.Printf("%s\n",strings.TrimSpace(string(outputs[i])))
24
+ desc, prs := configDesc[i]
25
+ if prs == false{
26
+
27
+ }else {
28
+ var output []string = strings.Split(string(outputs[i]),",")
29
+ fmt.Printf("value: %s -- %s \n",
30
+ strings.TrimSpace(string(output[3])),desc)
31
+ }
32
+ i = i + 1
33
+ }
34
+ },
35
+ }
36
+
37
+
38
+
839 RootCmd.AddCommand(config)
40
+ config.AddCommand(all)
941 }
1042
1143
....@@ -38,4 +70,42 @@
3870 idx: index of configure value
3971 typ: 0:num 1:str 2:ipv4 3:hw 4:isdn 5:ipv6
4072 val: value`,
73
+}
74
+
75
+
76
+var configDesc = map[int]string{
77
+ 0:"Probing Server On/Off",
78
+ 3:"script cache max-age",
79
+ 4:"system boot time",
80
+ 6:"dns CNAME (not implemented)",
81
+ 10:"Http 302 Location URL protocol://hostname",
82
+ 11:"dns operating mode 0:disabled, 1: enabled with A record",
83
+ 15:"dns answer A(ipv4) record ip",
84
+ 16:"dns answer AAAA(ipv6) record ip default is ::1/128",
85
+ 19:"current total nums of domains",
86
+ 20:"current total nums of user uri",
87
+ 21:"current total nums of telco(master) session",
88
+ 22:"current total nums of ADs service session",
89
+ 23:"current total nums of Parental Control service session",
90
+ 24:"current total nums of AD Blocker service session",
91
+ 25:"telco time machine backup, 0(all from boot), 3600(1hr),7200(2hr), 86400(1day)",
92
+ 26:"telco restored session count",
93
+ 41:"skip Injection & Tcp Reset when value=0 Tx is enabled",
94
+ 42:"skip user request log operations, value =0, log is enabled",
95
+ 43:"Router's external ip-address , It's activated only with compiling POC_ENABLED defined",
96
+ 44:"Simulated AAA's MSISDN , default is 010-200-3000, Activated only with compiling POC_ENABLED",
97
+ 45:"Exclude InApp browser(disabel=0),if this >0, enable and it's minimum agent's string length",
98
+ 46:"warning url of parental control (ex: http://warning.or.kr)",
99
+ 48:"http.302 AD[0] max count a day (<256)",
100
+ 49:"http.200 AD[1] max count a day (<256)",
101
+ 50:"http.302 AD[0] injection interval(sec)",
102
+ 51:"http.200 AD[1] injection interval(sec)",
103
+ 53:"staff's AD0 interval (same as MARKETING/9999 domain user's interval)",
104
+ 54:"staff's AD1 interval (same as MARKETING/9999 domain user's interval)",
105
+ 55:"AD0 injection count from boot",
106
+ 56:"AD1 injection count from boot",
107
+ 57:"policy, if '1', nevertheless adtime is 0, ads are displayed",
108
+ 58:"0: whitelist mode, 1: blacklist mode",
109
+ 59:"0: whitelist mode, 1: blacklist mode",
110
+ 60:"log level (0: nothing ) , see below table for more information",
41111 }
src/accessmotion.my/shell/shell.go
....@@ -6,7 +6,6 @@
66 "log"
77 "io"
88 "strings"
9
- "io/ioutil"
109 "strconv"
1110 "os/exec"
1211 )
....@@ -16,17 +15,6 @@
1615 io.WriteString(w, completer.Tree(" "))
1716 }
1817
19
-// Function constructor - constructs new function for listing given directory
20
-func listFiles(path string) func(string) []string {
21
- return func(line string) []string {
22
- names := make([]string, 0)
23
- files, _ := ioutil.ReadDir(path)
24
- for _, f := range files {
25
- names = append(names, f.Name())
26
- }
27
- return names
28
- }
29
-}
3018
3119 var completer = readline.NewPrefixCompleter(
3220
....@@ -367,7 +355,6 @@
367355 "uripath_pol":59,
368356 "debug_state":60,
369357 }
370
-
371358
372359 var configDesc = map[int]string{
373360 0:"Probing Server On/Off",