Update to match my protocol API changes branch

This commit is contained in:
John Brooks 2016-11-30 19:37:19 -08:00
parent a56dbfa5b9
commit c38ad18888
1 changed files with 9 additions and 10 deletions

View File

@ -109,20 +109,19 @@ func (pc *ProtocolConnection) OnContactRequestAck(channelID int32, status string
}
}
// Managing Channels
func (pc *ProtocolConnection) IsChannelAllowed(channelType string) bool {
switch channelType {
case "im.ricochet.auth.hidden-service":
return !pc.Conn.IsAuthed && pc.Contact == nil
case "im.ricochet.chat":
return pc.Conn.IsAuthed && pc.Contact != nil
case "im.ricochet.contact.request":
return pc.Conn.IsAuthed && pc.Contact == nil
func (pc *ProtocolConnection) IsKnownContact(hostname string) bool {
// All uses of this are for authenticated contacts, so it's sufficient to check pc.Contact
if pc.Contact != nil {
contactHostname, _ := PlainHostFromOnion(pc.Contact.Hostname())
if hostname != contactHostname {
log.Panicf("IsKnownContact called for unexpected hostname '%s'", hostname)
}
return true
}
return false
}
// Managing Channels
func (pc *ProtocolConnection) OnOpenChannelRequest(channelID int32, channelType string) {
log.Printf("open channel request: %v %v", channelID, channelType)
pc.Conn.AckOpenChannel(channelID, channelType)