Update to match my protocol API changes branch
This commit is contained in:
parent
a56dbfa5b9
commit
c38ad18888
|
@ -109,20 +109,19 @@ func (pc *ProtocolConnection) OnContactRequestAck(channelID int32, status string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Managing Channels
|
func (pc *ProtocolConnection) IsKnownContact(hostname string) bool {
|
||||||
func (pc *ProtocolConnection) IsChannelAllowed(channelType string) bool {
|
// All uses of this are for authenticated contacts, so it's sufficient to check pc.Contact
|
||||||
switch channelType {
|
if pc.Contact != nil {
|
||||||
case "im.ricochet.auth.hidden-service":
|
contactHostname, _ := PlainHostFromOnion(pc.Contact.Hostname())
|
||||||
return !pc.Conn.IsAuthed && pc.Contact == nil
|
if hostname != contactHostname {
|
||||||
case "im.ricochet.chat":
|
log.Panicf("IsKnownContact called for unexpected hostname '%s'", hostname)
|
||||||
return pc.Conn.IsAuthed && pc.Contact != nil
|
}
|
||||||
case "im.ricochet.contact.request":
|
return true
|
||||||
return pc.Conn.IsAuthed && pc.Contact == nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Managing Channels
|
||||||
func (pc *ProtocolConnection) OnOpenChannelRequest(channelID int32, channelType string) {
|
func (pc *ProtocolConnection) OnOpenChannelRequest(channelID int32, channelType string) {
|
||||||
log.Printf("open channel request: %v %v", channelID, channelType)
|
log.Printf("open channel request: %v %v", channelID, channelType)
|
||||||
pc.Conn.AckOpenChannel(channelID, channelType)
|
pc.Conn.AckOpenChannel(channelID, channelType)
|
||||||
|
|
Loading…
Reference in New Issue