Documentation ¶
Index ¶
- Constants
- func AfterReLoadConfig(pconfig *Config, old_config *FileConfig, new_config *FileConfig)
- func ClientIP(r *http.Request) string
- func ClientPublicIP(r *http.Request) string
- func CommSet(pconfig *Config) bool
- func GetFileType(fSrc []byte) string
- func HandleFileMsg(pconfig *Config, pmsg *FileMsg)
- func HandleReportCmd(pconfig *Config, pmsg *comm.ReportMsg)
- func HasLocalIP(ip net.IP) bool
- func HasLocalIPddr(ip string) bool
- func LocalSet(pconfig *Config) bool
- func ReadFileMsg(pconfig *Config)
- func ReadUploadMsg(pconfig *Config, pmsg *FileMsg)
- func RecvCommNotify(pconfig *Config, pnotify *ss.MsgCommonNotify, src_serv int)
- func RecvDispMsg(pconfig *Config, pdisp *ss.MsgDisp)
- func RecvFileTokenNotify(pconfig *Config, pnotify *ss.MsgCommonNotify, dir_serv int)
- func RecvHeartBeatReq(pconfig *Config, preq *ss.MsgHeartBeatReq, from int)
- func RecvMsg(pconfig *Config) int64
- func RecvReportCmd(arg interface{})
- func RecvUploadNotify(pconfig *Config, pnotify *ss.MsgCommonNotify)
- func ReportSyncServer(arg interface{})
- func SendHeartBeatMsg(arg interface{})
- func SendToDisp(pconfig *Config, hash_v int64, v interface{}) bool
- func SendToServ(pconfig *Config, target_serv int, v interface{}) bool
- func ServerExit(pconfig *Config)
- func ServerStart(pconfig *Config)
- func SyncServToken(arg interface{})
- func UpdateServToken(arg interface{})
- type AccMIME
- type Config
- type FileConfig
- type FileMsg
- type FileServer
- type MiMeRefer
- type Msg
- type UploadResult
Constants ¶
View Source
const ( UPLOAD_TMPL = "./html_tmpl/upload.html" //UPLOAD LABEL FORM_LABEL_URL_TYPE = "url_type" FORM_LABEL_UID = "uid" FORM_LABEL_GRP_ID = "grp_id" FORM_LABEL_TMP_ID = "tmp_id" FORM_LABEL_UPLOAD = "upload_file" FORM_LABEL_TOKEN = "token" //UPLOAD RESULT UPLOAD_RESULT_SUCCESS = 0 UPLOAD_RESULT_FAILED = 1 UPLOAD_RESULT_SIZE = 2 UPLOAD_RESULT_TYPE = 3 FILE_MSG_CHAN_SIZE = 1000 MAX_FETCH_PER_TICK = 10 //SUB_DIR --> type FILE_PARENT_DIR_CHATS = "chat" FILE_PARENT_DIR_HEADS = "head" FILE_PARENT_DIR_GROUP_HEADS = "g_head" //URL PATTERN URL_HEAD_CHATS = "/static" URL_HEAD_HEADS = "/head" URL_HEAD_G_HEADS = "/g_head" //FILE_MSG_TYPE FILE_MSG_EXIT = 0 //exit FILE_MSG_UPLOAD = 1 //server-->main upload one file FILE_MSG_UPLOAD_CHECK_FAIL = 2 //main-->server upload check err FILE_MSG_UPDATE_TOKEN = 3 //update token //MAX_SUB_DIR MAX_HEAD_SUB_DIRS = 64 //uid % dirs MAX_GROUP_HEAD_SUB_DIRS = 61 //grp_id % dirs //HTTPS KEY_FILE_PATH = "./cfg/key.pem" CERT_FILE_PATH = "./cfg/cert.pem" )
View Source
const ( //TOKEN LEN FILE_SERV_TOKEN_LEN = 10 PERIOD_UPDATE_TOKEN = 3600000 //1h update token PERIOD_SYNC_TOKEN = 600000 //10min sync token to dir //SAFE MOD SAFE_MOD_NONE = 0 SAFE_MOD_PATH = 1 //check path valid when query files SAFE_MOD_TOKEN = 2 //check token valid, will include above check when query files SAFE_MOD_IP = 3 //check ip valid,will include above check when query files. query failed times will record ip to blacklist //WATCHER SUSPECT_JAIL_TIME = 3600 //1h suspect ip in watcher if no fail again SUSPECT_SAFE_FAIL = 5 //most safe failed times SUSPECT_FAIL_PUNISH_SEC = 60 //overflow safe door, will block ip punish_sec per 1 failed access SUSPECT_CHECK_PEROID = 60 )
View Source
const (
MESSAGE_LEN = ss.MAX_SS_MSG_SIZE //200k
)
View Source
const (
RECV_FILE_MSG_TICK = 10
)
Variables ¶
This section is empty.
Functions ¶
func AfterReLoadConfig ¶
func AfterReLoadConfig(pconfig *Config, old_config *FileConfig, new_config *FileConfig)
After ReLoad Config If Need Handle
func ClientIP ¶
--------------code from gayhub -------------
refer https://github.com/thinkeridea/go-extend/tree/master/exnet ClientIP 尽最大努力实现获取客户端 IP 的算法。 解析 X-Real-IP 和 X-Forwarded-For 以便于反向代理(nginx 或 haproxy)可以正常工作。
func ClientPublicIP ¶
ClientPublicIP 尽最大努力实现获取客户端公网 IP 的算法。 解析 X-Real-IP 和 X-Forwarded-For 以便于反向代理(nginx 或 haproxy)可以正常工作。
func HandleFileMsg ¶
func HandleReportCmd ¶
func ReadFileMsg ¶
func ReadFileMsg(pconfig *Config)
func ReadUploadMsg ¶
func RecvCommNotify ¶
func RecvCommNotify(pconfig *Config, pnotify *ss.MsgCommonNotify, src_serv int)
func RecvDispMsg ¶
func RecvFileTokenNotify ¶
func RecvFileTokenNotify(pconfig *Config, pnotify *ss.MsgCommonNotify, dir_serv int)
dir --> file query
func RecvHeartBeatReq ¶
func RecvHeartBeatReq(pconfig *Config, preq *ss.MsgHeartBeatReq, from int)
func RecvReportCmd ¶
func RecvReportCmd(arg interface{})
func RecvUploadNotify ¶
func RecvUploadNotify(pconfig *Config, pnotify *ss.MsgCommonNotify)
func ReportSyncServer ¶
func ReportSyncServer(arg interface{})
func SendHeartBeatMsg ¶
func SendHeartBeatMsg(arg interface{})
func SendToDisp ¶
send to disp hash if hash_v>0 use hash first; or use rand method
func SendToServ ¶
@v only support []byte and *ss.SSMsg
func ServerExit ¶
func ServerExit(pconfig *Config)
func SyncServToken ¶
func SyncServToken(arg interface{})
func UpdateServToken ¶
func UpdateServToken(arg interface{})
Types ¶
type Config ¶
type Config struct { //comm NameSpace string ProcId int ProcName string ConfigFile string Daemon bool FileConfig *FileConfig Comm *comm.CommConfig ReportCmd string //used for report cmd ReportCmdToken int64 ReportServ *comm.ReportServ //report to manger //local NowToken string FileServer *FileServer //file server }
type FileConfig ¶
type FileConfig struct { DispServList []int `json:"disp_serv_list"` LogFile string `json:"log_file"` ServIndex int `json:"serv_index"` HttpAddr string `json:"http_addr"` MaxFileSize int `json:"max_file_size"` RealFilePath string `json:"real_file_path"` SafeMode int `json:"safe_mod"` //refer SAFE_MOD_XX ManageAddr []string `json:"manage_addr"` MonitorInv int `json:"monitor_inv"` //monitor interval seconds }
type FileServer ¶
func StartFileServer ¶
func StartFileServer(pconfig *Config) *FileServer
func (*FileServer) Close ¶
func (fs *FileServer) Close()
func (*FileServer) Read ¶
func (fs *FileServer) Read(msg_list []*FileMsg) int
upper read from FileServer
func (*FileServer) Suspect ¶
func (fs *FileServer) Suspect() int
type UploadResult ¶
Click to show internal directories.
Click to hide internal directories.