2019-05-09 12:18:12 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"reflect"
|
|
|
|
|
|
|
|
cluster "github.com/ipfs/ipfs-cluster"
|
|
|
|
)
|
|
|
|
|
|
|
|
func rpcTypeStr(t cluster.RPCEndpointType) string {
|
|
|
|
switch t {
|
|
|
|
case cluster.RPCClosed:
|
|
|
|
return "RPCClosed"
|
|
|
|
case cluster.RPCTrusted:
|
|
|
|
return "RPCTrusted"
|
|
|
|
case cluster.RPCOpen:
|
|
|
|
return "RPCOpen"
|
|
|
|
default:
|
|
|
|
return "ERROR"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2019-05-09 14:33:59 +00:00
|
|
|
rpcComponents := []interface{}{
|
2019-05-09 12:18:12 +00:00
|
|
|
&cluster.ClusterRPCAPI{},
|
|
|
|
&cluster.PinTrackerRPCAPI{},
|
|
|
|
&cluster.IPFSConnectorRPCAPI{},
|
|
|
|
&cluster.ConsensusRPCAPI{},
|
|
|
|
&cluster.PeerMonitorRPCAPI{},
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println(`
|
|
|
|
// The below generated policy keeps the endpoint types
|
|
|
|
// from the exiting one, marking new endpoints as NEW. Copy-paste this policy
|
2019-05-09 14:33:59 +00:00
|
|
|
// into rpc_auth.go and set the NEW endpoints to their correct type.`)
|
|
|
|
fmt.Println()
|
2019-05-09 12:18:12 +00:00
|
|
|
|
|
|
|
fmt.Println("var RPCPolicy = map[string]RPCEndpointType{")
|
|
|
|
|
|
|
|
for _, c := range rpcComponents {
|
|
|
|
t := reflect.TypeOf(c)
|
|
|
|
|
2019-05-09 14:33:59 +00:00
|
|
|
fmt.Println(" //", cluster.RPCServiceID(c), "methods")
|
2019-05-09 12:18:12 +00:00
|
|
|
for i := 0; i < t.NumMethod(); i++ {
|
|
|
|
method := t.Method(i)
|
2019-05-09 14:33:59 +00:00
|
|
|
name := fmt.Sprintf("%s.%s", cluster.RPCServiceID(c), method.Name)
|
2019-05-09 12:18:12 +00:00
|
|
|
rpcT, ok := cluster.DefaultRPCPolicy[name]
|
|
|
|
rpcTStr := "NEW"
|
|
|
|
if ok {
|
|
|
|
rpcTStr = rpcTypeStr(rpcT)
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Printf(" \"%s\": %s,\n", name, rpcTStr)
|
|
|
|
}
|
|
|
|
fmt.Println()
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println("}")
|
|
|
|
}
|