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
|
||||
}
|
||||
|
||||
func (m MockPeer) BlockUnknownConnections() {
|
||||
panic("should never be called")
|
||||
}
|
||||
|
||||
func (m MockPeer) AllowUnknownConnections() {
|
||||
panic("should never be called")
|
||||
}
|
||||
|
||||
func (m MockPeer) GetContacts() []string {
|
||||
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
|
||||
|
||||
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/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.3 h1:AifcbxK60UTeOiOt0ur8PLQeDCuljQLhLqrAOO/8guA=
|
||||
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/go.mod h1:xzzZ28adyUXNkYL1YodcHsAiTt3IJ8Loc29YVn9mIEQ=
|
||||
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()
|
||||
settingsJson, _ := json.Marshal(settings)
|
||||
|
||||
|
||||
newApp.LoadProfiles("be gay do crime")
|
||||
application = newApp
|
||||
|
||||
|
||||
|
||||
// Send global settings to the UI...
|
||||
application.GetPrimaryBus().Publish(event.NewEvent(utils.UpdateGlobalSettings, map[event.Field]string{event.Data: string(settingsJson)}))
|
||||
log.Infof("libcwtch-go application launched")
|
||||
|
@ -142,6 +145,19 @@ func SendAppEvent(eventJson string) {
|
|||
}
|
||||
log.Debugf("New Settings %v", 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:
|
||||
_, warn := new_event.Data[utils.Warn]
|
||||
_, 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.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
|
||||
profile.Listen()
|
||||
profile.StartPeersConnections()
|
||||
|
|
|
@ -26,6 +26,7 @@ type GlobalSettings struct {
|
|||
PreviousPid int64
|
||||
ExperimentsEnabled bool
|
||||
Experiments map[string]bool
|
||||
BlockUnknownConnections bool
|
||||
StateRootPane int
|
||||
FirstTime bool
|
||||
}
|
||||
|
@ -38,6 +39,7 @@ var DefaultGlobalSettings = GlobalSettings{
|
|||
Experiments: make(map[string]bool),
|
||||
StateRootPane: 0,
|
||||
FirstTime: true,
|
||||
BlockUnknownConnections: false,
|
||||
}
|
||||
|
||||
func InitGlobalSettingsFile(directory string, password string) error {
|
||||
|
|
Loading…
Reference in New Issue