Adding Block/Allow Unknown Contact Global Setting
continuous-integration/drone/pr Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
This commit is contained in:
parent
6e9d423d58
commit
fe84c6ac47
|
@ -14,6 +14,14 @@ type MockPeer struct {
|
||||||
peerRequest bool
|
peerRequest bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m MockPeer) BlockUnknownConnections() {
|
||||||
|
panic("should never be called")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m MockPeer) AllowUnknownConnections() {
|
||||||
|
panic("should never be called")
|
||||||
|
}
|
||||||
|
|
||||||
func (m MockPeer) GetContacts() []string {
|
func (m MockPeer) GetContacts() []string {
|
||||||
panic("should never be called")
|
panic("should never be called")
|
||||||
}
|
}
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module git.openprivacy.ca/flutter/libcwtch-go
|
||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cwtch.im/cwtch v0.6.3
|
cwtch.im/cwtch v0.6.4
|
||||||
git.openprivacy.ca/openprivacy/connectivity v1.3.3
|
git.openprivacy.ca/openprivacy/connectivity v1.3.3
|
||||||
git.openprivacy.ca/openprivacy/log v1.0.2
|
git.openprivacy.ca/openprivacy/log v1.0.2
|
||||||
)
|
)
|
2
go.sum
2
go.sum
|
@ -8,6 +8,8 @@ cwtch.im/cwtch v0.6.2 h1:UqwVnxNXvhhG7yGpcY9aXyq0dy31XzjV708BWCHHIms=
|
||||||
cwtch.im/cwtch v0.6.2/go.mod h1:snHZIZwRQPAZG2LRZsN5SpAIbeR597VJoDS+KHm7q9w=
|
cwtch.im/cwtch v0.6.2/go.mod h1:snHZIZwRQPAZG2LRZsN5SpAIbeR597VJoDS+KHm7q9w=
|
||||||
cwtch.im/cwtch v0.6.3 h1:AifcbxK60UTeOiOt0ur8PLQeDCuljQLhLqrAOO/8guA=
|
cwtch.im/cwtch v0.6.3 h1:AifcbxK60UTeOiOt0ur8PLQeDCuljQLhLqrAOO/8guA=
|
||||||
cwtch.im/cwtch v0.6.3/go.mod h1:snHZIZwRQPAZG2LRZsN5SpAIbeR597VJoDS+KHm7q9w=
|
cwtch.im/cwtch v0.6.3/go.mod h1:snHZIZwRQPAZG2LRZsN5SpAIbeR597VJoDS+KHm7q9w=
|
||||||
|
cwtch.im/cwtch v0.6.4 h1:7P7+c7pBw2/aGE1cVWWLlLWhkVrGwuhQomIRbWB840E=
|
||||||
|
cwtch.im/cwtch v0.6.4/go.mod h1:snHZIZwRQPAZG2LRZsN5SpAIbeR597VJoDS+KHm7q9w=
|
||||||
cwtch.im/tapir v0.2.1 h1:t1YJB9q5sV1A9xwiiwL6WVfw3dwQWLoecunuzT1PQtw=
|
cwtch.im/tapir v0.2.1 h1:t1YJB9q5sV1A9xwiiwL6WVfw3dwQWLoecunuzT1PQtw=
|
||||||
cwtch.im/tapir v0.2.1/go.mod h1:xzzZ28adyUXNkYL1YodcHsAiTt3IJ8Loc29YVn9mIEQ=
|
cwtch.im/tapir v0.2.1/go.mod h1:xzzZ28adyUXNkYL1YodcHsAiTt3IJ8Loc29YVn9mIEQ=
|
||||||
git.openprivacy.ca/openprivacy/bine v0.0.4 h1:CO7EkGyz+jegZ4ap8g5NWRuDHA/56KKvGySR6OBPW+c=
|
git.openprivacy.ca/openprivacy/bine v0.0.4 h1:CO7EkGyz+jegZ4ap8g5NWRuDHA/56KKvGySR6OBPW+c=
|
||||||
|
|
16
lib.go
16
lib.go
|
@ -94,9 +94,12 @@ func StartCwtch(appDir string, torPath string) {
|
||||||
settings := utils.ReadGlobalSettings()
|
settings := utils.ReadGlobalSettings()
|
||||||
settingsJson, _ := json.Marshal(settings)
|
settingsJson, _ := json.Marshal(settings)
|
||||||
|
|
||||||
|
|
||||||
newApp.LoadProfiles("be gay do crime")
|
newApp.LoadProfiles("be gay do crime")
|
||||||
application = newApp
|
application = newApp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Send global settings to the UI...
|
// Send global settings to the UI...
|
||||||
application.GetPrimaryBus().Publish(event.NewEvent(utils.UpdateGlobalSettings, map[event.Field]string{event.Data: string(settingsJson)}))
|
application.GetPrimaryBus().Publish(event.NewEvent(utils.UpdateGlobalSettings, map[event.Field]string{event.Data: string(settingsJson)}))
|
||||||
log.Infof("libcwtch-go application launched")
|
log.Infof("libcwtch-go application launched")
|
||||||
|
@ -142,6 +145,19 @@ func SendAppEvent(eventJson string) {
|
||||||
}
|
}
|
||||||
log.Debugf("New Settings %v", globalSettings)
|
log.Debugf("New Settings %v", globalSettings)
|
||||||
utils.WriteGlobalSettings(globalSettings)
|
utils.WriteGlobalSettings(globalSettings)
|
||||||
|
|
||||||
|
// Explicitly toggle blocking/unblocking of unknown connections for profiles
|
||||||
|
// that have been loaded.
|
||||||
|
if utils.ReadGlobalSettings().BlockUnknownConnections {
|
||||||
|
for onion := range application.ListPeers() {
|
||||||
|
application.GetPeer(onion).BlockUnknownConnections()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for onion := range application.ListPeers() {
|
||||||
|
application.GetPeer(onion).AllowUnknownConnections()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case utils.SetLoggingLevel:
|
case utils.SetLoggingLevel:
|
||||||
_, warn := new_event.Data[utils.Warn]
|
_, warn := new_event.Data[utils.Warn]
|
||||||
_, error := new_event.Data[utils.Error]
|
_, error := new_event.Data[utils.Error]
|
||||||
|
|
|
@ -68,6 +68,15 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
|
||||||
eh.app.AddPeerPlugin(onion, plugins.CONNECTIONRETRY)
|
eh.app.AddPeerPlugin(onion, plugins.CONNECTIONRETRY)
|
||||||
eh.app.AddPeerPlugin(onion, plugins.NETWORKCHECK)
|
eh.app.AddPeerPlugin(onion, plugins.NETWORKCHECK)
|
||||||
|
|
||||||
|
// If the user has chosen to block unknown profiles
|
||||||
|
// then explicitly configure the protocol engine to do so..
|
||||||
|
if ReadGlobalSettings().BlockUnknownConnections {
|
||||||
|
profile.BlockUnknownConnections()
|
||||||
|
} else {
|
||||||
|
// For completeness
|
||||||
|
profile.AllowUnknownConnections()
|
||||||
|
}
|
||||||
|
|
||||||
// Start up the Profile
|
// Start up the Profile
|
||||||
profile.Listen()
|
profile.Listen()
|
||||||
profile.StartPeersConnections()
|
profile.StartPeersConnections()
|
||||||
|
|
|
@ -26,6 +26,7 @@ type GlobalSettings struct {
|
||||||
PreviousPid int64
|
PreviousPid int64
|
||||||
ExperimentsEnabled bool
|
ExperimentsEnabled bool
|
||||||
Experiments map[string]bool
|
Experiments map[string]bool
|
||||||
|
BlockUnknownConnections bool
|
||||||
StateRootPane int
|
StateRootPane int
|
||||||
FirstTime bool
|
FirstTime bool
|
||||||
}
|
}
|
||||||
|
@ -38,6 +39,7 @@ var DefaultGlobalSettings = GlobalSettings{
|
||||||
Experiments: make(map[string]bool),
|
Experiments: make(map[string]bool),
|
||||||
StateRootPane: 0,
|
StateRootPane: 0,
|
||||||
FirstTime: true,
|
FirstTime: true,
|
||||||
|
BlockUnknownConnections: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitGlobalSettingsFile(directory string, password string) error {
|
func InitGlobalSettingsFile(directory string, password string) error {
|
||||||
|
|
Loading…
Reference in New Issue