github.com/cnotch/ipchub@v1.1.0/config/config.go (about)

     1  // Copyright (c) 2019,CAOHONGJU All rights reserved.
     2  // Use of this source code is governed by a MIT-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package config
     6  
     7  import (
     8  	"flag"
     9  )
    10  
    11  // config 服务配置
    12  type config struct {
    13  	ListenAddr  string          `json:"listen"`               // 服务侦听地址和端口
    14  	Auth        bool            `json:"auth"`                 // 启用安全验证
    15  	CacheGop    bool            `json:"cache_gop"`            // 缓存图像组,以便提高播放端打开速度,但内存需求大
    16  	HlsPath     string          `json:"hlspath"`              // Hls 临时缓存目录
    17  	HlsFragment int             `json:"hlsfragment"`          // Hls 分段时长,单位秒
    18  	Profile     bool            `json:"profile"`              // 是否启动Profile
    19  	TLS         *TLSConfig      `json:"tls,omitempty"`        // https安全端口交互
    20  	Routetable  *ProviderConfig `json:"routetable,omitempty"` // 路由表
    21  	Users       *ProviderConfig `json:"users,omitempty"`      // 用户
    22  	Log         LogConfig       `json:"log"`                  // 日志配置
    23  }
    24  
    25  func (c *config) initFlags() {
    26  	// 服务的端口
    27  	flag.StringVar(&c.ListenAddr, "listen", ":554", "Set server listen address")
    28  	flag.BoolVar(&c.Auth, "auth", false,
    29  		"Determines if requires permission verification to access stream media")
    30  	flag.BoolVar(&c.CacheGop, "cachegop", false,
    31  		"Determines if Gop should be cached to memory")
    32  	flag.StringVar(&c.HlsPath, "hlspath", "", "Set HLS live cache path")
    33  	flag.IntVar(&c.HlsFragment, "hlsfragment", 5, "Set HLS segment duration")
    34  	flag.BoolVar(&c.Profile, "pprof", false,
    35  		"Determines if profile enabled")
    36  
    37  	// 初始化日志配置
    38  	c.Log.initFlags()
    39  }