normalize all JSON to camelCase

Fixes #104.
This commit is contained in:
Jimmy Zelinskie 2015-10-25 16:53:23 -04:00
parent 7ae23bb2c6
commit 133450944c
4 changed files with 87 additions and 88 deletions

View file

@ -43,48 +43,47 @@ type DriverConfig struct {
// SubnetConfig is the configuration used to specify if local peers should be // SubnetConfig is the configuration used to specify if local peers should be
// given a preference when responding to an announce. // given a preference when responding to an announce.
type SubnetConfig struct { type SubnetConfig struct {
PreferredSubnet bool `json:"preferred_subnet,omitempty"` PreferredSubnet bool `json:"preferredSubnet,omitempty"`
PreferredIPv4Subnet int `json:"preferred_ipv4_subnet,omitempty"` PreferredIPv4Subnet int `json:"preferredIPv4Subnet,omitempty"`
PreferredIPv6Subnet int `json:"preferred_ipv6_subnet,omitempty"` PreferredIPv6Subnet int `json:"preferredIPv6Subnet,omitempty"`
} }
// NetConfig is the configuration used to tune networking behaviour. // NetConfig is the configuration used to tune networking behaviour.
type NetConfig struct { type NetConfig struct {
AllowIPSpoofing bool `json:"allow_ip_spoofing"` AllowIPSpoofing bool `json:"allowIPSpoofing"`
DualStackedPeers bool `json:"dual_stacked_peers"` DualStackedPeers bool `json:"dualStackedPeers"`
RealIPHeader string `json:"real_ip_header"` RealIPHeader string `json:"realIPHeader"`
RespectAF bool `json:"respect_af"` RespectAF bool `json:"respectAF"`
SubnetConfig SubnetConfig
} }
// StatsConfig is the configuration used to record runtime statistics. // StatsConfig is the configuration used to record runtime statistics.
type StatsConfig struct { type StatsConfig struct {
BufferSize int `json:"stats_buffer_size"` BufferSize int `json:"statsBufferSize"`
IncludeMem bool `json:"include_mem_stats"` IncludeMem bool `json:"includeMemStats"`
VerboseMem bool `json:"verbose_mem_stats"` VerboseMem bool `json:"verboseMemStats"`
MemUpdateInterval Duration `json:"memStatsInterval"`
MemUpdateInterval Duration `json:"mem_stats_interval"`
} }
// WhitelistConfig is the configuration used enable and store a whitelist of // WhitelistConfig is the configuration used enable and store a whitelist of
// acceptable torrent client peer ID prefixes. // acceptable torrent client peer ID prefixes.
type WhitelistConfig struct { type WhitelistConfig struct {
ClientWhitelistEnabled bool `json:"client_whitelist_enabled"` ClientWhitelistEnabled bool `json:"clientWhitelistEnabled"`
ClientWhitelist []string `json:"client_whitelist,omitempty"` ClientWhitelist []string `json:"clientWhitelist,omitempty"`
} }
// TrackerConfig is the configuration for tracker functionality. // TrackerConfig is the configuration for tracker functionality.
type TrackerConfig struct { type TrackerConfig struct {
CreateOnAnnounce bool `json:"create_on_announce"` CreateOnAnnounce bool `json:"createOnAnnounce"`
PrivateEnabled bool `json:"private_enabled"` PrivateEnabled bool `json:"privateEnabled"`
FreeleechEnabled bool `json:"freeleech_enabled"` FreeleechEnabled bool `json:"freeleechEnabled"`
PurgeInactiveTorrents bool `json:"purge_inactive_torrents"` PurgeInactiveTorrents bool `json:"purgeInactiveTorrents"`
Announce Duration `json:"announce"` Announce Duration `json:"announce"`
MinAnnounce Duration `json:"min_announce"` MinAnnounce Duration `json:"minAnnounce"`
ReapInterval Duration `json:"reap_interval"` ReapInterval Duration `json:"reapInterval"`
ReapRatio float64 `json:"reap_ratio"` ReapRatio float64 `json:"reapRatio"`
NumWantFallback int `json:"default_num_want"` NumWantFallback int `json:"defaultNumWant"`
TorrentMapShards int `json:"torrent_map_shards"` TorrentMapShards int `json:"torrentMapShards"`
NetConfig NetConfig
WhitelistConfig WhitelistConfig
@ -92,26 +91,26 @@ type TrackerConfig struct {
// APIConfig is the configuration for an HTTP JSON API server. // APIConfig is the configuration for an HTTP JSON API server.
type APIConfig struct { type APIConfig struct {
ListenAddr string `json:"api_listen_addr"` ListenAddr string `json:"apiListenAddr"`
RequestTimeout Duration `json:"api_request_timeout"` RequestTimeout Duration `json:"apiRequestTimeout"`
ReadTimeout Duration `json:"api_read_timeout"` ReadTimeout Duration `json:"apiReadTimeout"`
WriteTimeout Duration `json:"api_write_timeout"` WriteTimeout Duration `json:"apiWriteTimeout"`
ListenLimit int `json:"api_listen_limit"` ListenLimit int `json:"apiListenLimit"`
} }
// HTTPConfig is the configuration for the HTTP protocol. // HTTPConfig is the configuration for the HTTP protocol.
type HTTPConfig struct { type HTTPConfig struct {
ListenAddr string `json:"http_listen_addr"` ListenAddr string `json:"httpListenAddr"`
RequestTimeout Duration `json:"http_request_timeout"` RequestTimeout Duration `json:"httpRequestTimeout"`
ReadTimeout Duration `json:"http_read_timeout"` ReadTimeout Duration `json:"httpReadTimeout"`
WriteTimeout Duration `json:"http_write_timeout"` WriteTimeout Duration `json:"httpWriteTimeout"`
ListenLimit int `json:"http_listen_limit"` ListenLimit int `json:"httpListenLimit"`
} }
// UDPConfig is the configuration for the UDP protocol. // UDPConfig is the configuration for the UDP protocol.
type UDPConfig struct { type UDPConfig struct {
ListenAddr string `json:"udp_listen_addr"` ListenAddr string `json:"udpListenAddr"`
ReadBufferSize int `json:"udp_read_buffer_size"` ReadBufferSize int `json:"udpReadBufferSize"`
} }
// Config is the global configuration for an instance of Chihaya. // Config is the global configuration for an instance of Chihaya.

View file

@ -1,34 +1,34 @@
{ {
"create_on_announce": true, "createOnAnnounce": true,
"private_enabled": false, "privateEnabled": false,
"freeleech_enabled": false, "freeleechEnabled": false,
"purge_inactive_torrents": true, "purgeInactiveTorrents": true,
"announce": "30m", "announce": "30m",
"min_announce": "15m", "minAnnounce": "15m",
"reap_interval": "60s", "reapInterval": "60s",
"reap_ratio": "1.25", "reapRatio": "1.25",
"default_num_want": 50, "defaultNumWant": 50,
"torrent_map_shards": 1, "torrentMapShards": 1,
"allow_ip_spoofing": true, "allowIPSpoofing": true,
"dual_stacked_peers": true, "dualStackedPeers": true,
"real_ip_header": "", "realIPHeader": "",
"respect_af": false, "respectAF": false,
"client_whitelist_enabled": false, "clientWhitelistEnabled": false,
"client_whitelist": ["OP1011"], "clientWhitelist": ["OP1011"],
"api_listen_addr": ":6880", "apiListenAddr": ":6880",
"api_request_timeout": "4s", "apiRequestTimeout": "4s",
"api_read_timeout": "4s", "apiReadTimeout": "4s",
"api_write_timeout": "4s", "apiWriteTimeout": "4s",
"api_listen_limit": 0, "apiListenLimit": 0,
"udp_listen_addr": ":6881", "udpListenAddr": ":6881",
"http_listen_addr": ":6881", "httpListenAddr": ":6881",
"http_request_timeout": "4s", "httpRequestTimeout": "4s",
"http_read_timeout": "4s", "httpReadTimeout": "4s",
"http_write_timeout": "4s", "httpWriteTimeout": "4s",
"http_listen_limit": 0, "httpListenLimit": 0,
"driver": "noop", "driver": "noop",
"stats_buffer_size": 0, "statsBufferSize": 0,
"include_mem_stats": true, "includeMemStats": true,
"verbose_mem_stats": false, "verboseMemStats": false,
"mem_stats_interval": "5s" "memStatsInterval": "5s"
} }

View file

@ -69,27 +69,27 @@ type PercentileTimes struct {
type Stats struct { type Stats struct {
Started time.Time // Time at which Chihaya was booted. Started time.Time // Time at which Chihaya was booted.
OpenConnections int64 `json:"Connections.Open"` OpenConnections int64 `json:"connectionsOpen"`
ConnectionsAccepted uint64 `json:"Connections.Accepted"` ConnectionsAccepted uint64 `json:"connectionsAccepted"`
BytesTransmitted uint64 `json:"BytesTransmitted"` BytesTransmitted uint64 `json:"bytesTransmitted"`
GoRoutines int `json:"Runtime.GoRoutines"` GoRoutines int `json:"runtimeGoRoutines"`
RequestsHandled uint64 `json:"Requests.Handled"` RequestsHandled uint64 `json:"requestsHandled"`
RequestsErrored uint64 `json:"Requests.Errored"` RequestsErrored uint64 `json:"requestsErrored"`
ClientErrors uint64 `json:"Requests.Bad"` ClientErrors uint64 `json:"requestsBad"`
ResponseTime PercentileTimes ResponseTime PercentileTimes
Announces uint64 `json:"Tracker.Announces"` Announces uint64 `json:"trackerAnnounces"`
Scrapes uint64 `json:"Tracker.Scrapes"` Scrapes uint64 `json:"trackerScrapes"`
TorrentsSize uint64 `json:"Torrents.Size"` TorrentsSize uint64 `json:"torrentsSize"`
TorrentsAdded uint64 `json:"Torrents.Added"` TorrentsAdded uint64 `json:"torrentsAdded"`
TorrentsRemoved uint64 `json:"Torrents.Removed"` TorrentsRemoved uint64 `json:"torrentsRemoved"`
TorrentsReaped uint64 `json:"Torrents.Reaped"` TorrentsReaped uint64 `json:"torrentsReaped"`
IPv4Peers PeerStats `json:"Peers.IPv4"` IPv4Peers PeerStats `json:"peersIPv4"`
IPv6Peers PeerStats `json:"Peers.IPv6"` IPv6Peers PeerStats `json:"peersIPv6"`
*MemStatsWrapper `json:",omitempty"` *MemStatsWrapper `json:",omitempty"`

View file

@ -88,12 +88,12 @@ type Endpoint struct {
// Peer is a participant in a swarm. // Peer is a participant in a swarm.
type Peer struct { type Peer struct {
ID string `json:"id"` ID string `json:"id"`
UserID uint64 `json:"user_id"` UserID uint64 `json:"userId"`
TorrentID uint64 `json:"torrent_id"` TorrentID uint64 `json:"torrentId"`
Uploaded uint64 `json:"uploaded"` Uploaded uint64 `json:"uploaded"`
Downloaded uint64 `json:"downloaded"` Downloaded uint64 `json:"downloaded"`
Left uint64 `json:"left"` Left uint64 `json:"left"`
LastAnnounce int64 `json:"last_announce"` LastAnnounce int64 `json:"lastAnnounce"`
Endpoint Endpoint
} }
@ -123,9 +123,9 @@ type Torrent struct {
Leechers *PeerMap `json:"leechers"` Leechers *PeerMap `json:"leechers"`
Snatches uint64 `json:"snatches"` Snatches uint64 `json:"snatches"`
UpMultiplier float64 `json:"up_multiplier"` UpMultiplier float64 `json:"upMultiplier"`
DownMultiplier float64 `json:"down_multiplier"` DownMultiplier float64 `json:"downMultiplier"`
LastAction int64 `json:"last_action"` LastAction int64 `json:"lastAction"`
} }
// PeerCount returns the total number of peers connected on this Torrent. // PeerCount returns the total number of peers connected on this Torrent.
@ -138,8 +138,8 @@ type User struct {
ID uint64 `json:"id"` ID uint64 `json:"id"`
Passkey string `json:"passkey"` Passkey string `json:"passkey"`
UpMultiplier float64 `json:"up_multiplier"` UpMultiplier float64 `json:"upMultiplier"`
DownMultiplier float64 `json:"down_multiplier"` DownMultiplier float64 `json:"downMultiplier"`
} }
// Announce is an Announce by a Peer. // Announce is an Announce by a Peer.