mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-01-22 15:08:12 -05:00
Try to revert proxy settings if possible. Fix #140.
This commit is contained in:
parent
d44a52b593
commit
ca71a9a7d9
@ -175,6 +175,7 @@ options.watchProxyChange (details) ->
|
|||||||
return unless details
|
return unless details
|
||||||
notControllableBefore = options.proxyNotControllable()
|
notControllableBefore = options.proxyNotControllable()
|
||||||
internal = false
|
internal = false
|
||||||
|
noRevert = false
|
||||||
switch details['levelOfControl']
|
switch details['levelOfControl']
|
||||||
when "controlled_by_other_extensions", "not_controllable"
|
when "controlled_by_other_extensions", "not_controllable"
|
||||||
reason =
|
reason =
|
||||||
@ -183,6 +184,7 @@ options.watchProxyChange (details) ->
|
|||||||
else
|
else
|
||||||
'app'
|
'app'
|
||||||
options.setProxyNotControllable(reason)
|
options.setProxyNotControllable(reason)
|
||||||
|
noRevert = true
|
||||||
else
|
else
|
||||||
options.setProxyNotControllable(null)
|
options.setProxyNotControllable(null)
|
||||||
|
|
||||||
@ -200,7 +202,7 @@ options.watchProxyChange (details) ->
|
|||||||
clearTimeout(timeout) if timeout?
|
clearTimeout(timeout) if timeout?
|
||||||
parsed = null
|
parsed = null
|
||||||
timeout = setTimeout (->
|
timeout = setTimeout (->
|
||||||
options.setExternalProfile(parsed, {noRevert: true, internal: internal})
|
options.setExternalProfile(parsed, {noRevert: noRevert, internal: internal})
|
||||||
), 500
|
), 500
|
||||||
|
|
||||||
parsed = options.parseExternalProfile(details)
|
parsed = options.parseExternalProfile(details)
|
||||||
|
@ -4,7 +4,7 @@ module.exports = ->
|
|||||||
"-refreshOnProfileChange": true
|
"-refreshOnProfileChange": true
|
||||||
"-startupProfileName": ""
|
"-startupProfileName": ""
|
||||||
"-quickSwitchProfiles": []
|
"-quickSwitchProfiles": []
|
||||||
"-revertProxyChanges": false
|
"-revertProxyChanges": true
|
||||||
"-confirmDeletion": true
|
"-confirmDeletion": true
|
||||||
"-showInspectMenu": true
|
"-showInspectMenu": true
|
||||||
"-downloadInterval": 1440
|
"-downloadInterval": 1440
|
||||||
|
@ -20,6 +20,7 @@ class Options
|
|||||||
_storage: null
|
_storage: null
|
||||||
_state: null
|
_state: null
|
||||||
_currentProfileName: null
|
_currentProfileName: null
|
||||||
|
_revertToProfileName: null
|
||||||
_watchingProfiles: {}
|
_watchingProfiles: {}
|
||||||
_tempProfile: null
|
_tempProfile: null
|
||||||
_tempProfileRules: {}
|
_tempProfileRules: {}
|
||||||
@ -774,11 +775,14 @@ class Options
|
|||||||
# @returns {Promise} A promise which is fulfilled when the profile is set
|
# @returns {Promise} A promise which is fulfilled when the profile is set
|
||||||
###
|
###
|
||||||
setExternalProfile: (profile, args) ->
|
setExternalProfile: (profile, args) ->
|
||||||
if not args?.noRevert and @_options['-revertProxyChanges']
|
if @_options['-revertProxyChanges'] and not @_isSystem
|
||||||
if profile.name != @_currentProfileName and @_currentProfileName
|
if profile.name != @_currentProfileName and @_currentProfileName
|
||||||
if not @_isSystem
|
if not args?.noRevert
|
||||||
@applyProfile(@_currentProfileName)
|
@applyProfile(@_revertToProfileName)
|
||||||
|
@_revertToProfileName = null
|
||||||
return
|
return
|
||||||
|
else
|
||||||
|
@_revertToProfileName ?= @_currentProfileName
|
||||||
p = OmegaPac.Profiles.byName(profile.name, @_options)
|
p = OmegaPac.Profiles.byName(profile.name, @_options)
|
||||||
if p
|
if p
|
||||||
if args?.internal
|
if args?.internal
|
||||||
|
Loading…
Reference in New Issue
Block a user