-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from TRON-US/ipfs-0.5.1
Upgrade to upstream ipfs 0.5.1
- Loading branch information
Showing
19 changed files
with
435 additions
and
162 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
go-btfs-config | ||
================== | ||
|
||
> go-btfs configuration datastructure. | ||
Documentation lives in the go-btfs repo: [docs/config.md](https://github.com/TRON-US/go-btfs/blob/master/docs/config.md). | ||
|
||
## Table of Contents | ||
|
||
- [Contribute](#contribute) | ||
- [License](#license) | ||
|
||
## Contribute | ||
|
||
PRs are welcome! | ||
|
||
Small note: If editing the Readme, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification. | ||
|
||
## License | ||
|
||
MIT © TRON-US |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// AutoNATServiceMode configures the ipfs node's AutoNAT service. | ||
type AutoNATServiceMode int | ||
|
||
const ( | ||
// AutoNATServiceUnset indicates that the user has not set the | ||
// AutoNATService mode. | ||
// | ||
// When unset, nodes configured to be public DHT nodes will _also_ | ||
// perform limited AutoNAT dialbacks. | ||
AutoNATServiceUnset AutoNATServiceMode = iota | ||
// AutoNATServiceEnabled indicates that the user has enabled the | ||
// AutoNATService. | ||
AutoNATServiceEnabled | ||
// AutoNATServiceDisabled indicates that the user has disabled the | ||
// AutoNATService. | ||
AutoNATServiceDisabled | ||
) | ||
|
||
func (m *AutoNATServiceMode) UnmarshalText(text []byte) error { | ||
switch string(text) { | ||
case "": | ||
*m = AutoNATServiceUnset | ||
case "enabled": | ||
*m = AutoNATServiceEnabled | ||
case "disabled": | ||
*m = AutoNATServiceDisabled | ||
default: | ||
return fmt.Errorf("unknown autonat mode: %s", string(text)) | ||
} | ||
return nil | ||
} | ||
|
||
func (m AutoNATServiceMode) MarshalText() ([]byte, error) { | ||
switch m { | ||
case AutoNATServiceUnset: | ||
return nil, nil | ||
case AutoNATServiceEnabled: | ||
return []byte("enabled"), nil | ||
case AutoNATServiceDisabled: | ||
return []byte("disabled"), nil | ||
default: | ||
return nil, fmt.Errorf("unknown autonat mode: %d", m) | ||
} | ||
} | ||
|
||
// AutoNATConfig configures the node's AutoNAT subsystem. | ||
type AutoNATConfig struct { | ||
// ServiceMode configures the node's AutoNAT service mode. | ||
ServiceMode AutoNATServiceMode `json:",omitempty"` | ||
|
||
// Throttle configures AutoNAT dialback throttling. | ||
// | ||
// If unset, the conservative libp2p defaults will be unset. To help the | ||
// network, please consider setting this and increasing the limits. | ||
// | ||
// By default, the limits will be a total of 30 dialbacks, with a | ||
// per-peer max of 3 peer, resetting every minute. | ||
Throttle *AutoNATThrottleConfig `json:",omitempty"` | ||
} | ||
|
||
// AutoNATThrottleConfig configures the throttle limites | ||
type AutoNATThrottleConfig struct { | ||
// GlobalLimit and PeerLimit sets the global and per-peer dialback | ||
// limits. The AutoNAT service will only perform the specified number of | ||
// dialbacks per interval. | ||
// | ||
// Setting either to 0 will disable the appropriate limit. | ||
GlobalLimit, PeerLimit int | ||
|
||
// Interval specifies how frequently this node should reset the | ||
// global/peer dialback limits. | ||
// | ||
// When unset, this defaults to 1 minute. | ||
Interval Duration `json:",omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,71 @@ | ||
package config | ||
|
||
type GatewaySpec struct { | ||
// Paths is explicit list of path prefixes that should be handled by | ||
// this gateway. Example: `["/ipfs", "/ipns", "/api"]` | ||
Paths []string | ||
|
||
// UseSubdomains indicates whether or not this gateway uses subdomains | ||
// for IPFS resources instead of paths. That is: http://CID.ipfs.GATEWAY/... | ||
// | ||
// If this flag is set, any /ipns/$id and/or /ipfs/$id paths in PathPrefixes | ||
// will be permanently redirected to http://$id.[ipns|ipfs].$gateway/. | ||
// | ||
// We do not support using both paths and subdomains for a single domain | ||
// for security reasons (Origin isolation). | ||
UseSubdomains bool | ||
|
||
// NoDNSLink configures this gateway to _not_ resolve DNSLink for the FQDN | ||
// provided in `Host` HTTP header. | ||
NoDNSLink bool | ||
} | ||
|
||
// Gateway contains options for the HTTP gateway server. | ||
type Gateway struct { | ||
HTTPHeaders map[string][]string // HTTP headers to return with the gateway | ||
|
||
// HTTPHeaders configures the headers that should be returned by this | ||
// gateway. | ||
HTTPHeaders map[string][]string // HTTP headers to return with the gateway | ||
|
||
// RootRedirect is the path to which requests to `/` on this gateway | ||
// should be redirected. | ||
RootRedirect string | ||
Writable bool | ||
|
||
// Writable enables PUT/POST request handling by this gateway. Usually, | ||
// writing is done through the API, not the gateway. | ||
Writable bool | ||
|
||
// PathPrefixes is an array of acceptable url paths that a client can | ||
// specify in X-Ipfs-Path-Prefix header. | ||
// | ||
// The X-Ipfs-Path-Prefix header is used to specify a base path to prepend | ||
// to links in directory listings and for trailing-slash redirects. It is | ||
// intended to be set by a frontend http proxy like nginx. | ||
// | ||
// Example: To mount blog.ipfs.io (a DNSLink site) at ipfs.io/blog | ||
// set PathPrefixes to ["/blog"] and nginx config to translate paths | ||
// and pass Host header (for DNSLink): | ||
// location /blog/ { | ||
// rewrite "^/blog(/.*)$" $1 break; | ||
// proxy_set_header Host blog.ipfs.io; | ||
// proxy_set_header X-Ipfs-Gateway-Prefix /blog; | ||
// proxy_pass http://127.0.0.1:8080; | ||
// } | ||
PathPrefixes []string | ||
APICommands []string | ||
NoFetch bool | ||
|
||
// FIXME: Not yet implemented | ||
APICommands []string | ||
|
||
// NoFetch configures the gateway to _not_ fetch blocks in response to | ||
// requests. | ||
NoFetch bool | ||
|
||
// NoDNSLink configures the gateway to _not_ perform DNS TXT record | ||
// lookups in response to requests with values in `Host` HTTP header. | ||
// This flag can be overriden per FQDN in PublicGateways. | ||
NoDNSLink bool | ||
|
||
// PublicGateways configures behavior of known public gateways. | ||
// Each key is a fully qualified domain name (FQDN). | ||
PublicGateways map[string]*GatewaySpec | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.