コード例 #1
0
ファイル: cmd.go プロジェクト: BillSun/asuran
func (p *Proxy) Command(commands string, f *profile.Profile, v *life.Life) {
	commandLines := strings.Split(commands, "\n")
	for _, line := range commandLines {
		line = strings.TrimSpace(line)
		if len(line) <= 0 || line[0] == '#' {
			continue
		}

		c, rest := cmd.TakeFirstArg(line)
		switch c {
		case "restart":
			if v != nil {
				v.Restart()
			}
		case "clear":
			f.Clear()
		case "delay":
			f.CommandDelay(rest)
		case "proxy":
			f.CommandProxy(rest)
		case "delete":
			f.CommandDelete(rest)
		case "domain":
			f.CommandDomain(rest)
		case "url":
			f.CommandUrl(rest)
		default:
			if ip, domain, ok := parseIPDomain(c, rest); ok {
				f.CommandDomain("redirect " + domain + " " + ip)
				break
			}
		}
	}
}