mirror of
https://github.com/ipfs/kubo.git
synced 2025-05-17 23:16:11 +08:00
feat(routing/http): support IPIP-484 and streaming (#10534)
This commit is contained in:
@ -3,12 +3,29 @@ package config
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultAcceleratedDHTClient = false
|
||||
DefaultLoopbackAddressesOnLanDHT = false
|
||||
)
|
||||
|
||||
var (
|
||||
DefaultAcceleratedDHTClient = false
|
||||
DefaultLoopbackAddressesOnLanDHT = false
|
||||
// Default HTTP routers used in parallel to DHT when Routing.Type = "auto"
|
||||
DefaultHTTPRouters = getEnvOrDefault("IPFS_HTTP_ROUTERS", []string{
|
||||
"https://cid.contact", // https://github.com/ipfs/kubo/issues/9422#issuecomment-1338142084
|
||||
})
|
||||
|
||||
// Default filter-protocols to pass along with delegated routing requests (as defined in IPIP-484)
|
||||
// and also filter out locally
|
||||
DefaultHTTPRoutersFilterProtocols = getEnvOrDefault("IPFS_HTTP_ROUTERS_FILTER_PROTOCOLS", []string{
|
||||
"unknown", // allow results without protocol list, we can do libp2p identify to test them
|
||||
"transport-bitswap",
|
||||
// TODO: add 'transport-ipfs-gateway-http' once https://github.com/ipfs/rainbow/issues/125 is addressed
|
||||
})
|
||||
)
|
||||
|
||||
// Routing defines configuration options for libp2p routing.
|
||||
@ -180,3 +197,13 @@ type ConfigRouter struct {
|
||||
type Method struct {
|
||||
RouterName string
|
||||
}
|
||||
|
||||
// getEnvOrDefault reads space or comma separated strings from env if present,
|
||||
// and uses provided defaultValue as a fallback
|
||||
func getEnvOrDefault(key string, defaultValue []string) []string {
|
||||
if value, exists := os.LookupEnv(key); exists {
|
||||
splitFunc := func(r rune) bool { return r == ',' || r == ' ' }
|
||||
return strings.FieldsFunc(value, splitFunc)
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
|
Reference in New Issue
Block a user