コード例 #1
0
ファイル: smtp.go プロジェクト: bjxujiang/goblet
func (s *_SmtpSender) ParseConfig() (err error) {
	s.Root = toml.String("mail.root", "./mail")
	s.Server = toml.String("mail.server", "")
	s.User = toml.String("mail.user", "")
	s.Pwd = toml.String("mail.password", "")
	s.Ttl = toml.Bool("mail.ttl", false)
	s.Port = toml.Int("mail.port", 465)
	*s.Root = filepath.FromSlash(*s.Root)
	return
}
コード例 #2
0
ファイル: config.go プロジェクト: extrame/goblet
func (s *Server) AddConfig(name string, obj interface{}) {
	UnmarshalForm(func(tag string) []string {
		pText := toml.String(name+"."+tag, "")
		toml.Load()
		if *pText != "" {
			return []string{*pText}
		} else {
			return []string{}
		}

	}, obj, true)
}
コード例 #3
0
ファイル: server.go プロジェクト: extrame/goblet
func (s *Server) parseConfig() (err error) {
	path := flag.String("config", "./"+s.name+".conf", "设置配置文件的路径")
	for _, plugin := range s.plugins {
		plugin.ParseConfig()
	}
	s.wwwRoot = toml.String("basic.www_root", "./www")
	s.ListenPort = toml.Int("basic.port", 8080)
	s.readTimeOut = toml.Int("basic.read_timeout", 30)
	s.writeTimeOut = toml.Int("basic.write_timeout", 30)
	s.publicDir = toml.String("basic.public_dir", "public")
	s.UploadsDir = toml.String("basic.uploads_dir", "./uploads")
	s.IgnoreUrlCase = toml.Bool("basic.ignore_url_case", true)
	s.HashSecret = toml.String("secret", "cX8Os0wfB6uCGZZSZHIi6rKsy7b0scE9")
	s.env = toml.String("basic.env", config.ProductEnv)
	s.dbEngine = toml.String("basic.db_engine", "mysql")
	s.enDbCache = toml.Bool("cache.enable", false)
	s.cacheAmout = toml.Int("cache.amount", 1000)
	s.logFile = toml.String("log.file", "")
	s.version = toml.String("basic.version", "")
	flag.Parse()
	*path = filepath.FromSlash(*path)
	err = toml.Parse(*path)
	if err == nil {
		s.initLog()
		s.dbHost = toml.String(*s.dbEngine+".host", s.name)
		s.dbUser = toml.String(*s.dbEngine+".user", "")
		s.dbPwd = toml.String(*s.dbEngine+".password", "")
		s.dbName = toml.String(*s.dbEngine+".name", "")
		s.dbPort = toml.Int(*s.dbEngine+".port", 3306)
		s.dbConTO = toml.Int(*s.dbEngine+".connect_timeout", 30)
		s.dbKaInterval = toml.Int(*s.dbEngine+".ka_interval", 0)
		err = toml.Load()
	}
	return
}
コード例 #4
0
ファイル: config.go プロジェクト: BobbWu/syler
package config

import (
	toml "github.com/extrame/go-toml-config"
	"net"
	"strings"
)

var (
	RadiusEnable        = toml.Bool("radius.enabled", false)
	RadiusAuthPort      = toml.Int("radius.port", 1812)
	RadiusAccPort       = toml.Int("radius.acc_port", 1813)
	RadiusSecret        = toml.String("radius.secret", "testing123")
	HttpPort            = toml.Int("http.port", 8080)
	HttpWhiteList       = toml.String("http.white_list", "")
	RandomUser          = toml.Bool("basic.random_user", true)
	LogFile             = toml.String("basic.logfile", "")
	CallBackUrl         = toml.String("basic.callback_logout", "")
	UseRemoteIpAsUserIp = toml.Bool("basic.remote_ip_as_user_ip", false)
	HuaweiPort          = toml.Int("huawei.port", 50100)
	HuaweiVersion       = toml.Int("huawei.version", 1)
	HuaweiTimeout       = toml.Int("huawei.timeout", 15)
	HuaweiSecret        = toml.String("huawei.secret", "testing123")
	HuaweiNasPort       = toml.Int("huawei.nas_port", 2000)
	HuaweiDomain        = toml.String("huawei.domain", "huawei.com")
	LoginPage           = toml.String("basic.login_page", "./login.html")
	NasIp               = toml.String("basic.nas_ip", "")
	DefaultTimeout      = toml.Uint64("basic.default_timeout", 0)
	AuthType            = toml.String("radius.auth_type", "random")
)