ability to choose external router from options

dbus-notify
Zlatin Balevsky 2022-03-05 21:20:32 +00:00
parent 9f62fb6256
commit 746027c07d
No known key found for this signature in database
GPG Key ID: A72832072D525E41
4 changed files with 92 additions and 17 deletions

View File

@ -51,7 +51,10 @@ class OptionsController {
i2pProps["inbound.quantity"] = String.valueOf(tunnelQuantity)
i2pProps["outbound.quantity"] = String.valueOf(tunnelQuantity)
if (settings.embeddedRouter) {
final boolean embeddedAvailable = System.getProperty("embeddedRouter") == "true"
if (embeddedAvailable) {
settings.embeddedRouter = model.embeddedRouter
text = view.i2pNTCPPortField.text
model.i2pNTCPPort = text
i2pProps["i2np.ntcp.port"] = text
@ -65,6 +68,14 @@ class OptionsController {
i2pProps["i2np.upnp.enable"] = String.valueOf(useUPNP)
i2pProps["i2np.upnp.ipv6.enable"] = String.valueOf(useUPNP)
}
text = view.i2cpHostField.text
model.i2cpHost = text
i2pProps['i2cp.tcp.host'] = text
text = view.i2cpPortField.text
model.i2cpPort = text
i2pProps['i2cp.tcp.port'] = text
File i2pSettingsFile = new File(core.home, "i2p.properties")
@ -161,7 +172,7 @@ class OptionsController {
settings.incompleteLocation = new File(incompleteLocation)
}
if (settings.embeddedRouter) {
if (embeddedAvailable) {
text = view.inBwField.text
model.inBw = text
settings.inBw = Integer.valueOf(text)

View File

@ -335,6 +335,9 @@ OPTIONS_DOWNLOAD_UPDATES=Download updates automatically
# I2P tab
OPTIONS_CHANGING_I2P_SETTINGS=Changing any I2P settings requires a restart
OPTIONS_TUNNEL_SETTINGS=Tunnel Settings
OPTIONS_ROUTER_TYPE=Router Type
OPTIONS_EMBEDDED=Embedded
OPTIONS_EXTERNAL=External
# GUI tab
OPTIONS_THEME_SETTINGS=Theme Settings
@ -823,6 +826,8 @@ TOOLTIP_OPTIONS_ADVERTISE_FEED=Let others know about your file feed when you sen
TOOLTIP_OPTIONS_PUBLISH_SHARED=Publish files to your feed as soon as they are shared
TOOLTIP_OPTIONS_ONLY_TRUSTED=Connect only to users in your contact list
TOOLTIP_OPTIONS_SEARCH_EXTRA_HOP=Search an extra hop. If enabled your search may reach users not in your contact list
TOOLTIP_OPTIONS_EMBEDDED=Use the embedded router that comes with MuWire
TOOLTIP_OPTIONS_EXTERNAL=Use an external I2P or I2Pd router
## Tooltips for Tools
TOOLTIP_TOOLS_FOLDER_CONFIGURE=Configure properties of the selected folder

View File

@ -41,6 +41,9 @@ class OptionsModel {
@Observable String i2pUDPPort
@Observable String i2pNTCPPort
@Observable boolean useUPNP
@Observable String i2cpHost
@Observable String i2cpPort
@Observable boolean embeddedRouter
// gui options
@Observable boolean showMonitor
@ -129,6 +132,9 @@ class OptionsModel {
i2pUDPPort = core.i2pOptions["i2np.udp.port"]
i2pNTCPPort = core.i2pOptions["i2np.ntcp.port"]
useUPNP = Boolean.parseBoolean(core.i2pOptions.getProperty("i2np.upnp.enable","true"))
i2cpHost = core.i2pOptions["i2cp.tcp.host"]
i2cpPort = core.i2pOptions["i2cp.tcp.port"]
embeddedRouter = core.muOptions.embeddedRouter
UISettings uiSettings = application.context.get("ui-settings")
showMonitor = uiSettings.showMonitor

View File

@ -75,6 +75,8 @@ class OptionsView {
def i2pUDPPortField
def i2pNTCPPortField
def useUPNPCheckbox
def i2cpHostField
def i2cpPortField
def monitorCheckbox
def lnfComboBox
@ -311,23 +313,56 @@ class OptionsView {
paintLabels : true)
}
Core core = application.context.get("core")
if (core.router != null) {
panel(border : titledBorder(title : trans("PORT_SETTINGS"), border : etchedBorder(), titlePosition : TitledBorder.TOP,
constraints : gbc(gridx: 0, gridy : 2, fill : GridBagConstraints.HORIZONTAL, weightx: 100))) {
if ("true" != System.getProperty("embeddedRouter")) {
panel(border: titledBorder(title: trans("EXTERNAL_ROUTER_I2CP_SETTINGS"), border: etchedBorder(), titlePosition: TitledBorder.TOP,
constraints: gbc(gridx: 0, gridy: 2, fill: GridBagConstraints.HORIZONTAL, weightx: 100))) {
gridBagLayout()
label(text : trans("TCP_PORT"), toolTipText: trans("TOOLTIP_OPTIONS_TCP_PORT"),
constraints : gbc(gridx :0, gridy: 0, anchor : GridBagConstraints.LINE_START, weightx : 100))
i2pNTCPPortField = textField(text : bind {model.i2pNTCPPort}, columns : COLUMNS, horizontalAlignment: JTextField.RIGHT,
label(text: trans("HOST"),
constraints: gbc(gridx: 0, gridy: 0, anchor: GridBagConstraints.LINE_START, weightx: 100))
i2cpHostField = textField(text : bind {model.i2cpHost}, columns: COLUMNS, horizontalAlignment: JTextField.RIGHT,
constraints : gbc(gridx:1, gridy:0, anchor : GridBagConstraints.LINE_END))
label(text : trans("UDP_PORT"), toolTipText: trans("TOOLTIP_OPTIONS_UDP_PORT"),
constraints : gbc(gridx :0, gridy: 1, anchor : GridBagConstraints.LINE_START, weightx : 100))
i2pUDPPortField = textField(text : bind {model.i2pUDPPort}, columns : COLUMNS, horizontalAlignment: JTextField.RIGHT,
label(text : trans("PORT"),
constraints: gbc(gridx: 0, gridy: 1, anchor: GridBagConstraints.LINE_START, weightx: 100))
i2cpPortField = textField(text : bind {model.i2cpPort}, columns: COLUMNS, horizontalAlignment: JTextField.RIGHT,
constraints : gbc(gridx:1, gridy:1, anchor : GridBagConstraints.LINE_END))
}
} else {
panel(border: titledBorder(title: trans("OPTIONS_ROUTER_TYPE"), border: etchedBorder(), titlePosition: TitledBorder.TOP,
constraints: gbc(gridx: 0, gridy: 2, fill: GridBagConstraints.HORIZONTAL, weightx: 100))) {
buttonGroup(id: "routerType")
radioButton(text : trans("OPTIONS_EMBEDDED"), toolTipText: trans("TOOLTIP_OPTIONS_EMBEDDED"),
selected: bind {model.embeddedRouter}, actionPerformed : switchToEmbedded)
radioButton(text : trans("OPTIONS_EXTERNAL"), toolTipText: trans("TOOLTIP_OPTIONS_EXTERNAL"),
selected: bind {!model.embeddedRouter}, actionPerformed : switchToExternal)
}
panel(id : "router-props", constraints: gbc(gridx: 0, gridy: 3, fill: GridBagConstraints.HORIZONTAL, weightx: 100)) {
cardLayout()
panel(id : "router-props-embedded", border: titledBorder(title: trans("PORT_SETTINGS"), border: etchedBorder(), titlePosition: TitledBorder.TOP)) {
gridBagLayout()
label(text: trans("TCP_PORT"), toolTipText: trans("TOOLTIP_OPTIONS_TCP_PORT"),
constraints: gbc(gridx: 0, gridy: 0, anchor: GridBagConstraints.LINE_START, weightx: 100))
i2pNTCPPortField = textField(text: bind { model.i2pNTCPPort }, columns: COLUMNS, horizontalAlignment: JTextField.RIGHT,
constraints : gbc(gridx:1, gridy:0, anchor : GridBagConstraints.LINE_END))
label(text : trans("USE_UPNP"), constraints: gbc(gridx:0, gridy: 2, anchor: GridBagConstraints.LINE_START, weightx: 100))
useUPNPCheckbox = checkBox(selected: bind {model.useUPNP}, constraints: gbc(gridx: 1, gridy: 2, anchor: GridBagConstraints.LINE_END))
label(text : trans("UDP_PORT"), toolTipText: trans("TOOLTIP_OPTIONS_UDP_PORT"),
constraints : gbc(gridx:0, gridy: 1, anchor: GridBagConstraints.LINE_START, weightx: 100))
i2pUDPPortField = textField(text: bind { model.i2pUDPPort }, columns: COLUMNS, horizontalAlignment: JTextField.RIGHT,
constraints : gbc(gridx:1, gridy:1, anchor : GridBagConstraints.LINE_END))
label(text : trans("USE_UPNP"), constraints: gbc(gridx:0, gridy: 2, anchor: GridBagConstraints.LINE_START, weightx: 100))
useUPNPCheckbox = checkBox(selected: bind {model.useUPNP }, constraints: gbc(gridx: 1, gridy: 2, anchor: GridBagConstraints.LINE_END))
}
panel(id : "router-props-external", border: titledBorder(title: trans("EXTERNAL_ROUTER_I2CP_SETTINGS"), border: etchedBorder(), titlePosition: TitledBorder.TOP)) {
gridBagLayout()
label(text: trans("HOST"),
constraints: gbc(gridx: 0, gridy: 0, anchor: GridBagConstraints.LINE_START, weightx: 100))
i2cpHostField = textField(text : bind {model.i2cpHost}, columns: COLUMNS, horizontalAlignment: JTextField.RIGHT,
constraints : gbc(gridx:1, gridy:0, anchor : GridBagConstraints.LINE_END))
label(text : trans("PORT"),
constraints: gbc(gridx: 0, gridy: 1, anchor: GridBagConstraints.LINE_START, weightx: 100))
i2cpPortField = textField(text : bind {model.i2cpPort}, columns: COLUMNS, horizontalAlignment: JTextField.RIGHT,
constraints : gbc(gridx:1, gridy:1, anchor : GridBagConstraints.LINE_END))
}
}
}
panel(constraints : gbc(gridx: 0, gridy: 3, weighty: 100))
@ -552,6 +587,18 @@ class OptionsView {
}
}
def switchToEmbedded = {
model.embeddedRouter = true
def cardsPanel = builder.getVariable("router-props")
cardsPanel.getLayout().show(cardsPanel, "router-props-embedded")
}
def switchToExternal = {
model.embeddedRouter = false
def cardsPanel = builder.getVariable("router-props")
cardsPanel.getLayout().show(cardsPanel, "router-props-external")
}
boolean isAqua() {
// this is a Java bug. File choosers don't appear on Aqua L&F.
model.lnfClassName == "system" && SystemVersion.isMac()
@ -562,10 +609,15 @@ class OptionsView {
tabbedPane.addTab("MuWire", p)
tabbedPane.addTab("I2P", i)
tabbedPane.addTab(trans("GUI"), u)
Core core = application.context.get("core")
if (core.router != null) {
if (System.getProperty("embeddedRouter") == "true") {
tabbedPane.addTab(trans("BANDWIDTH"), bandwidth)
if (model.embeddedRouter)
switchToEmbedded.call()
else
switchToExternal.call()
}
tabbedPane.addTab(trans("FEED"), feed)
tabbedPane.addTab(trans("TRUST_NOUN"), trust)
tabbedPane.addTab(trans("COMMUNICATIONS"), chat)
@ -575,6 +627,7 @@ class OptionsView {
panel.add(tabbedPane, BorderLayout.CENTER)
panel.add(buttonsPanel, BorderLayout.SOUTH)
d.getContentPane().add(panel)
d.pack()
d.setLocationRelativeTo(mainFrame)