feat: add domain field to SMB host options

This commit is contained in:
hstyi
2025-10-30 15:08:10 +08:00
committed by hstyi
parent d07f9ede8c
commit 4c928ac826
6 changed files with 14 additions and 3 deletions

View File

@@ -2,7 +2,7 @@ plugins {
alias(libs.plugins.kotlin.jvm) alias(libs.plugins.kotlin.jvm)
} }
project.version = "0.0.3" project.version = "0.0.4"
dependencies { dependencies {
testImplementation(kotlin("test")) testImplementation(kotlin("test"))

View File

@@ -42,6 +42,7 @@ class SMBHostOptionsPane : OptionsPane() {
sftpDefaultDirectory = sftpOption.defaultDirectoryField.text, sftpDefaultDirectory = sftpOption.defaultDirectoryField.text,
extras = mutableMapOf( extras = mutableMapOf(
"smb.share" to generalOption.shareTextField.text, "smb.share" to generalOption.shareTextField.text,
"smb.domain" to generalOption.domainTextField.text,
) )
) )
@@ -66,6 +67,7 @@ class SMBHostOptionsPane : OptionsPane() {
generalOption.remarkTextArea.text = host.remark generalOption.remarkTextArea.text = host.remark
generalOption.passwordTextField.text = host.authentication.password generalOption.passwordTextField.text = host.authentication.password
generalOption.shareTextField.text = host.options.extras["smb.share"] ?: StringUtils.EMPTY generalOption.shareTextField.text = host.options.extras["smb.share"] ?: StringUtils.EMPTY
generalOption.domainTextField.text = host.options.extras["smb.domain"] ?: StringUtils.EMPTY
sftpOption.defaultDirectoryField.text = host.options.sftpDefaultDirectory sftpOption.defaultDirectoryField.text = host.options.sftpDefaultDirectory
} }
@@ -114,6 +116,7 @@ class SMBHostOptionsPane : OptionsPane() {
val nameTextField = OutlineTextField(128) val nameTextField = OutlineTextField(128)
val shareTextField = OutlineTextField(256) val shareTextField = OutlineTextField(256)
val usernameTextField = OutlineComboBox<String>() val usernameTextField = OutlineComboBox<String>()
val domainTextField = OutlineTextField(128)
val hostTextField = OutlineTextField(255) val hostTextField = OutlineTextField(255)
val passwordTextField = OutlinePasswordField(255) val passwordTextField = OutlinePasswordField(255)
val remarkTextArea = FixedLengthTextArea(512) val remarkTextArea = FixedLengthTextArea(512)
@@ -188,7 +191,9 @@ class SMBHostOptionsPane : OptionsPane() {
.add(portTextField).xy(7, rows).apply { rows += step } .add(portTextField).xy(7, rows).apply { rows += step }
.add("${I18n.getString("termora.new-host.general.username")}:").xy(1, rows) .add("${I18n.getString("termora.new-host.general.username")}:").xy(1, rows)
.add(usernameTextField).xyw(3, rows, 5).apply { rows += step } .add(usernameTextField).xy(3, rows)
.add("${SMBI18n.getString("termora.plugins.smb.domain")}:").xy(5, rows)
.add(domainTextField).xy(7, rows).apply { rows += step }
.add("${I18n.getString("termora.new-host.general.password")}:").xy(1, rows) .add("${I18n.getString("termora.new-host.general.password")}:").xy(1, rows)
.add(passwordTextField).xyw(3, rows, 5).apply { rows += step } .add(passwordTextField).xyw(3, rows, 5).apply { rows += step }

View File

@@ -30,6 +30,7 @@ class SMBProtocolProvider private constructor() : TransferProtocolProvider {
val client = SMBClient() val client = SMBClient()
val host = requester.host val host = requester.host
val connection = client.connect(host.host, host.port) val connection = client.connect(host.host, host.port)
val domain = host.options.extras["smb.domain"] ?: StringUtils.EMPTY
val session = when (host.username) { val session = when (host.username) {
"Guest" -> connection.authenticate(AuthenticationContext.guest()) "Guest" -> connection.authenticate(AuthenticationContext.guest())
"Anonymous" -> connection.authenticate(AuthenticationContext.anonymous()) "Anonymous" -> connection.authenticate(AuthenticationContext.anonymous())
@@ -37,7 +38,7 @@ class SMBProtocolProvider private constructor() : TransferProtocolProvider {
AuthenticationContext( AuthenticationContext(
host.username, host.username,
host.authentication.password.toCharArray(), host.authentication.password.toCharArray(),
null domain.ifBlank { null }
) )
) )
} }

View File

@@ -1 +1,2 @@
termora.plugins.smb.share=Share name termora.plugins.smb.share=Share name
termora.plugins.smb.domain=Domain

View File

@@ -1 +1,3 @@
termora.plugins.smb.share=共享名称 termora.plugins.smb.share=共享名称
termora.plugins.smb.domain=域名

View File

@@ -1 +1,3 @@
termora.plugins.smb.share=共享名稱 termora.plugins.smb.share=共享名稱
termora.plugins.smb.domain=網域