-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Push Publishing #82
Push Publishing #82
Conversation
@@ -323,3 +325,8 @@ func (node *Node) doShutdown() { | |||
node.ds.Close() | |||
os.Exit(0) | |||
} | |||
|
|||
func (node *Node) authorizePush(pid p2p_peer.ID, ns []string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's just make a little table of permitted peers:namespaces for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, more like a table to a list of namespaces (with wildcard support)
Looking good so far |
@@ -119,7 +119,7 @@ func NATConfigFromString(str string) (cfg NATConfig, err error) { | |||
} | |||
|
|||
func GetPublicIP() (string, error) { | |||
res, err := http.Get("http://ifconfig.me/ip") | |||
res, err := http.Get("http://ifconfig.co/ip") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice to fallback through a couple/one that we run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that's probably a good idea.
The code running ifconfig.co is available at github: https://github.com/martinp/ipd
So we can run it at ifconfig.medichain.io
and have fallback to ifconfig.co
.
I'll open an enhancement issue and add support once we have the ifconfing server up.
|
||
func (auth *PeerAuth) fromJSON(rmap map[string]interface{}) error { | ||
auth.mx.Lock() | ||
defer auth.mx.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this just executes when it goes out of scope? weird. I guess it's like a finally
a bit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's more like unwind-protect
at function-scope.
Each function has an unwind stack, where defer pushes thunks. And at the function epilogue, the unwind stack is poped and the thunks are executed.
return true | ||
|
||
case strings.HasSuffix(rule, ".*"): | ||
if strings.HasPrefix(ns, rule[:len(rule)-2]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about foo.bar.*.*
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm, I don't think it's worth the trouble.
I kept it simple and used the same wildcard semantics we have in MCQL.
If it proves to be insufficient for some use case, we can generalize to support regexps.
Implement the
/mediachain/node/push
protocol for accepting pushes from authorized peers.Semantics are those of an inverted merge: the source pushes statements, and the receiver merges them and requests objects by reusing the merge protocol implementation.
Closes #23
Implementation:
Also: changes mc/nat public ip detection service to ifconfig.co, as ifconfig.me appears to be busted.
Examples
/auth
api: