diff --git a/config/config.go b/config/config.go index b91903b..9072530 100644 --- a/config/config.go +++ b/config/config.go @@ -43,48 +43,47 @@ type DriverConfig struct { // SubnetConfig is the configuration used to specify if local peers should be // given a preference when responding to an announce. type SubnetConfig struct { - PreferredSubnet bool `json:"preferred_subnet,omitempty"` - PreferredIPv4Subnet int `json:"preferred_ipv4_subnet,omitempty"` - PreferredIPv6Subnet int `json:"preferred_ipv6_subnet,omitempty"` + PreferredSubnet bool `json:"preferredSubnet,omitempty"` + PreferredIPv4Subnet int `json:"preferredIPv4Subnet,omitempty"` + PreferredIPv6Subnet int `json:"preferredIPv6Subnet,omitempty"` } // NetConfig is the configuration used to tune networking behaviour. type NetConfig struct { - AllowIPSpoofing bool `json:"allow_ip_spoofing"` - DualStackedPeers bool `json:"dual_stacked_peers"` - RealIPHeader string `json:"real_ip_header"` - RespectAF bool `json:"respect_af"` + AllowIPSpoofing bool `json:"allowIPSpoofing"` + DualStackedPeers bool `json:"dualStackedPeers"` + RealIPHeader string `json:"realIPHeader"` + RespectAF bool `json:"respectAF"` SubnetConfig } // StatsConfig is the configuration used to record runtime statistics. type StatsConfig struct { - BufferSize int `json:"stats_buffer_size"` - IncludeMem bool `json:"include_mem_stats"` - VerboseMem bool `json:"verbose_mem_stats"` - - MemUpdateInterval Duration `json:"mem_stats_interval"` + BufferSize int `json:"statsBufferSize"` + IncludeMem bool `json:"includeMemStats"` + VerboseMem bool `json:"verboseMemStats"` + MemUpdateInterval Duration `json:"memStatsInterval"` } // WhitelistConfig is the configuration used enable and store a whitelist of // acceptable torrent client peer ID prefixes. type WhitelistConfig struct { - ClientWhitelistEnabled bool `json:"client_whitelist_enabled"` - ClientWhitelist []string `json:"client_whitelist,omitempty"` + ClientWhitelistEnabled bool `json:"clientWhitelistEnabled"` + ClientWhitelist []string `json:"clientWhitelist,omitempty"` } // TrackerConfig is the configuration for tracker functionality. type TrackerConfig struct { - CreateOnAnnounce bool `json:"create_on_announce"` - PrivateEnabled bool `json:"private_enabled"` - FreeleechEnabled bool `json:"freeleech_enabled"` - PurgeInactiveTorrents bool `json:"purge_inactive_torrents"` + CreateOnAnnounce bool `json:"createOnAnnounce"` + PrivateEnabled bool `json:"privateEnabled"` + FreeleechEnabled bool `json:"freeleechEnabled"` + PurgeInactiveTorrents bool `json:"purgeInactiveTorrents"` Announce Duration `json:"announce"` - MinAnnounce Duration `json:"min_announce"` - ReapInterval Duration `json:"reap_interval"` - ReapRatio float64 `json:"reap_ratio"` - NumWantFallback int `json:"default_num_want"` - TorrentMapShards int `json:"torrent_map_shards"` + MinAnnounce Duration `json:"minAnnounce"` + ReapInterval Duration `json:"reapInterval"` + ReapRatio float64 `json:"reapRatio"` + NumWantFallback int `json:"defaultNumWant"` + TorrentMapShards int `json:"torrentMapShards"` NetConfig WhitelistConfig @@ -92,26 +91,26 @@ type TrackerConfig struct { // APIConfig is the configuration for an HTTP JSON API server. type APIConfig struct { - ListenAddr string `json:"api_listen_addr"` - RequestTimeout Duration `json:"api_request_timeout"` - ReadTimeout Duration `json:"api_read_timeout"` - WriteTimeout Duration `json:"api_write_timeout"` - ListenLimit int `json:"api_listen_limit"` + ListenAddr string `json:"apiListenAddr"` + RequestTimeout Duration `json:"apiRequestTimeout"` + ReadTimeout Duration `json:"apiReadTimeout"` + WriteTimeout Duration `json:"apiWriteTimeout"` + ListenLimit int `json:"apiListenLimit"` } // HTTPConfig is the configuration for the HTTP protocol. type HTTPConfig struct { - ListenAddr string `json:"http_listen_addr"` - RequestTimeout Duration `json:"http_request_timeout"` - ReadTimeout Duration `json:"http_read_timeout"` - WriteTimeout Duration `json:"http_write_timeout"` - ListenLimit int `json:"http_listen_limit"` + ListenAddr string `json:"httpListenAddr"` + RequestTimeout Duration `json:"httpRequestTimeout"` + ReadTimeout Duration `json:"httpReadTimeout"` + WriteTimeout Duration `json:"httpWriteTimeout"` + ListenLimit int `json:"httpListenLimit"` } // UDPConfig is the configuration for the UDP protocol. type UDPConfig struct { - ListenAddr string `json:"udp_listen_addr"` - ReadBufferSize int `json:"udp_read_buffer_size"` + ListenAddr string `json:"udpListenAddr"` + ReadBufferSize int `json:"udpReadBufferSize"` } // Config is the global configuration for an instance of Chihaya. diff --git a/example_config.json b/example_config.json index 1df454a..12621c0 100644 --- a/example_config.json +++ b/example_config.json @@ -1,34 +1,34 @@ { - "create_on_announce": true, - "private_enabled": false, - "freeleech_enabled": false, - "purge_inactive_torrents": true, + "createOnAnnounce": true, + "privateEnabled": false, + "freeleechEnabled": false, + "purgeInactiveTorrents": true, "announce": "30m", - "min_announce": "15m", - "reap_interval": "60s", - "reap_ratio": "1.25", - "default_num_want": 50, - "torrent_map_shards": 1, - "allow_ip_spoofing": true, - "dual_stacked_peers": true, - "real_ip_header": "", - "respect_af": false, - "client_whitelist_enabled": false, - "client_whitelist": ["OP1011"], - "api_listen_addr": ":6880", - "api_request_timeout": "4s", - "api_read_timeout": "4s", - "api_write_timeout": "4s", - "api_listen_limit": 0, - "udp_listen_addr": ":6881", - "http_listen_addr": ":6881", - "http_request_timeout": "4s", - "http_read_timeout": "4s", - "http_write_timeout": "4s", - "http_listen_limit": 0, + "minAnnounce": "15m", + "reapInterval": "60s", + "reapRatio": "1.25", + "defaultNumWant": 50, + "torrentMapShards": 1, + "allowIPSpoofing": true, + "dualStackedPeers": true, + "realIPHeader": "", + "respectAF": false, + "clientWhitelistEnabled": false, + "clientWhitelist": ["OP1011"], + "apiListenAddr": ":6880", + "apiRequestTimeout": "4s", + "apiReadTimeout": "4s", + "apiWriteTimeout": "4s", + "apiListenLimit": 0, + "udpListenAddr": ":6881", + "httpListenAddr": ":6881", + "httpRequestTimeout": "4s", + "httpReadTimeout": "4s", + "httpWriteTimeout": "4s", + "httpListenLimit": 0, "driver": "noop", - "stats_buffer_size": 0, - "include_mem_stats": true, - "verbose_mem_stats": false, - "mem_stats_interval": "5s" + "statsBufferSize": 0, + "includeMemStats": true, + "verboseMemStats": false, + "memStatsInterval": "5s" } diff --git a/stats/stats.go b/stats/stats.go index abe366c..e3a00fc 100644 --- a/stats/stats.go +++ b/stats/stats.go @@ -69,27 +69,27 @@ type PercentileTimes struct { type Stats struct { Started time.Time // Time at which Chihaya was booted. - OpenConnections int64 `json:"Connections.Open"` - ConnectionsAccepted uint64 `json:"Connections.Accepted"` - BytesTransmitted uint64 `json:"BytesTransmitted"` + OpenConnections int64 `json:"connectionsOpen"` + ConnectionsAccepted uint64 `json:"connectionsAccepted"` + BytesTransmitted uint64 `json:"bytesTransmitted"` - GoRoutines int `json:"Runtime.GoRoutines"` + GoRoutines int `json:"runtimeGoRoutines"` - RequestsHandled uint64 `json:"Requests.Handled"` - RequestsErrored uint64 `json:"Requests.Errored"` - ClientErrors uint64 `json:"Requests.Bad"` + RequestsHandled uint64 `json:"requestsHandled"` + RequestsErrored uint64 `json:"requestsErrored"` + ClientErrors uint64 `json:"requestsBad"` ResponseTime PercentileTimes - Announces uint64 `json:"Tracker.Announces"` - Scrapes uint64 `json:"Tracker.Scrapes"` + Announces uint64 `json:"trackerAnnounces"` + Scrapes uint64 `json:"trackerScrapes"` - TorrentsSize uint64 `json:"Torrents.Size"` - TorrentsAdded uint64 `json:"Torrents.Added"` - TorrentsRemoved uint64 `json:"Torrents.Removed"` - TorrentsReaped uint64 `json:"Torrents.Reaped"` + TorrentsSize uint64 `json:"torrentsSize"` + TorrentsAdded uint64 `json:"torrentsAdded"` + TorrentsRemoved uint64 `json:"torrentsRemoved"` + TorrentsReaped uint64 `json:"torrentsReaped"` - IPv4Peers PeerStats `json:"Peers.IPv4"` - IPv6Peers PeerStats `json:"Peers.IPv6"` + IPv4Peers PeerStats `json:"peersIPv4"` + IPv6Peers PeerStats `json:"peersIPv6"` *MemStatsWrapper `json:",omitempty"` diff --git a/tracker/models/models.go b/tracker/models/models.go index 9962c93..65e67f8 100644 --- a/tracker/models/models.go +++ b/tracker/models/models.go @@ -88,12 +88,12 @@ type Endpoint struct { // Peer is a participant in a swarm. type Peer struct { ID string `json:"id"` - UserID uint64 `json:"user_id"` - TorrentID uint64 `json:"torrent_id"` + UserID uint64 `json:"userId"` + TorrentID uint64 `json:"torrentId"` Uploaded uint64 `json:"uploaded"` Downloaded uint64 `json:"downloaded"` Left uint64 `json:"left"` - LastAnnounce int64 `json:"last_announce"` + LastAnnounce int64 `json:"lastAnnounce"` Endpoint } @@ -123,9 +123,9 @@ type Torrent struct { Leechers *PeerMap `json:"leechers"` Snatches uint64 `json:"snatches"` - UpMultiplier float64 `json:"up_multiplier"` - DownMultiplier float64 `json:"down_multiplier"` - LastAction int64 `json:"last_action"` + UpMultiplier float64 `json:"upMultiplier"` + DownMultiplier float64 `json:"downMultiplier"` + LastAction int64 `json:"lastAction"` } // PeerCount returns the total number of peers connected on this Torrent. @@ -138,8 +138,8 @@ type User struct { ID uint64 `json:"id"` Passkey string `json:"passkey"` - UpMultiplier float64 `json:"up_multiplier"` - DownMultiplier float64 `json:"down_multiplier"` + UpMultiplier float64 `json:"upMultiplier"` + DownMultiplier float64 `json:"downMultiplier"` } // Announce is an Announce by a Peer.