Documentation ¶
Index ¶
- Constants
- Variables
- func CheckConf(conf *Conf)
- func CmpClipboard(a *Clipboard, b *Clipboard) bool
- func GetMD5Hash(text string) string
- func IndexClipboardArray(arr []Clipboard, item *Clipboard) int
- func InitFlags(conf *Conf)
- func InitLogger(c *Conf)
- func NewModuleLogger(module_name string) *logrus.Entry
- func ParseTimeStr(t string) int64
- func RandString(size int) string
- func TokenEncrypt(token string) string
- func UrlDownloadApi(c *Conf, fileName string) string
- func UrlPullApi(c *Conf) string
- func UrlPushApi(c *Conf) string
- func UrlUploadApi(c *Conf) string
- type Clipboard
- type Conf
- type FileMetadata
- type ServerResponse
Constants ¶
View Source
const ( ApiPrefix = "api" ApiVersion = "v0" ApiPublic = "public" Api_Push = "push" Api_Pull = "pull" Api_History = "history" Api_Upload = "upload" Api_Download = "download/*filename" Api_DownloadPure = "download" )
Variables ¶
View Source
var Version string = "v0.0.0"
Functions ¶
func CmpClipboard ¶
func GetMD5Hash ¶
func IndexClipboardArray ¶
func InitLogger ¶
func InitLogger(c *Conf)
func NewModuleLogger ¶
func RandString ¶
func TokenEncrypt ¶
func UrlDownloadApi ¶
func UrlPullApi ¶
func UrlPushApi ¶
func UrlUploadApi ¶
Types ¶
type Clipboard ¶
type Clipboard struct { Id int64 `json:"-" db:"id"` Ts int64 `json:"ts" db:"ts"` //ms timestamp Content string `json:"content" db:"content"` Hostname string `json:"hostname" db:"hostname"` // sender ContentType string `json:"content_type" db:"content_type"` // }
func NewClipoardWithDefault ¶
func NewClipoardWithDefault() *Clipboard
func NewFullClipoard ¶
It generates the hostname so take care of where it is called
type Conf ¶
type Conf struct { Token string `toml:"token"` Client struct { ServerUrl string `toml:"server_url"` Connect string `toml:"connect"` Adapter string `toml:"adapter"` Interval int `toml:"interval"` Timeout int64 `toml:"timeout"` XSelection string `toml:"X_selection"` } `toml:"client"` Server struct { DBPath string `toml:"db_path"` PullHistorySize int `toml:"pull_history_size"` TmpPath string `toml:"tmp_path"` DefaultFileLife int64 `toml:"default_file_life"` TimerInterval int `toml:"timer_interval"` ClipboardHistoryPageSize int `toml:"clipboard_history_page_size"` Port int `toml:"port"` CacheMaxAge int `toml:"cache_max_age"` } `toml:"server"` // All struct should be read-only except runtime after LoadConf Runtime struct { Mode string ConfPath string LogLevel string PushMsg string Download string Upload string Pull bool Latest bool Test string TokenEncrypt string ShowVersion bool LogPath string ShowHelp bool UploadFileLifetime int64 UploadFileLifetimeStr string } }
func FormatConf ¶
func NewConfWithDefault ¶
func NewConfWithDefault() *Conf
Why go-toml? because gin need it! Default tag is not supported by go-toml now,so I have to implement this
type FileMetadata ¶
type FileMetadata struct { Id int64 `json:"-" db:"id"` CreatedTs int64 `json:"created_ts" db:"created_ts"` //ms timestamp ExpireTs int64 `json:"expire_ts" db:"expire_ts"` //ms timestamp FileName string `json:"file_name" db:"file_name"` TmpPath string `json:"tmp_path" db:"tmp_path"` //relative path based on the tmpPath in conf }
func NewFileMetadataWithDefault ¶
func NewFileMetadataWithDefault() *FileMetadata
type ServerResponse ¶
type ServerResponse struct { Msg string `json:"msg"` Data json.RawMessage `json:"data"` }
func NewDefaultServeRes ¶
func NewDefaultServeRes(msg string, data []byte) *ServerResponse
Click to show internal directories.
Click to hide internal directories.