Fix Transmission remote connection issues
- Prevent remote host from defaulting to localhost - Preserve remote connection settings during config updates - Handle empty values correctly to avoid overriding good config 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
f28d49284e
commit
301684886f
@ -39,8 +39,11 @@ class TransmissionClient {
|
||||
const { host, port, username, password, path: rpcPath } = this.config.transmissionConfig;
|
||||
|
||||
try {
|
||||
// Only default to localhost if host is empty/null/undefined
|
||||
const connectionHost = (host === undefined || host === null || host === '') ? 'localhost' : host;
|
||||
|
||||
this.client = new Transmission({
|
||||
host: host || 'localhost',
|
||||
host: connectionHost,
|
||||
port: port || 9091,
|
||||
username: username || '',
|
||||
password: password || '',
|
||||
@ -48,7 +51,7 @@ class TransmissionClient {
|
||||
timeout: 30000 // 30 seconds
|
||||
});
|
||||
|
||||
console.log(`Initialized Transmission client connection to ${host}:${port}${rpcPath}`);
|
||||
console.log(`Initialized Transmission client connection to ${connectionHost}:${port}${rpcPath}`);
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize Transmission client:', error);
|
||||
throw error;
|
||||
|
42
server.js
42
server.js
@ -468,9 +468,45 @@ app.post('/api/config', authenticateJWT, async (req, res) => {
|
||||
// Merge the new config with the existing one
|
||||
const newConfig = { ...config, ...req.body };
|
||||
|
||||
// Keep passwords if they're not provided
|
||||
if (newConfig.transmissionConfig && !newConfig.transmissionConfig.password && config.transmissionConfig) {
|
||||
newConfig.transmissionConfig.password = config.transmissionConfig.password;
|
||||
// Preserve existing Transmission configuration values when not explicitly provided
|
||||
if (newConfig.transmissionConfig && config.transmissionConfig) {
|
||||
// First create a copy of the existing configuration
|
||||
const preservedTransConfig = { ...config.transmissionConfig };
|
||||
|
||||
// Only update values that are explicitly provided and not empty
|
||||
if (!req.body.transmissionConfig?.host) {
|
||||
newConfig.transmissionConfig.host = preservedTransConfig.host;
|
||||
}
|
||||
|
||||
if (!req.body.transmissionConfig?.port) {
|
||||
newConfig.transmissionConfig.port = preservedTransConfig.port;
|
||||
}
|
||||
|
||||
if (!req.body.transmissionConfig?.path) {
|
||||
newConfig.transmissionConfig.path = preservedTransConfig.path;
|
||||
}
|
||||
|
||||
if (!req.body.transmissionConfig?.username) {
|
||||
newConfig.transmissionConfig.username = preservedTransConfig.username;
|
||||
}
|
||||
|
||||
// Always preserve password if not provided
|
||||
if (!newConfig.transmissionConfig.password) {
|
||||
newConfig.transmissionConfig.password = preservedTransConfig.password;
|
||||
}
|
||||
}
|
||||
|
||||
// Preserve remote configuration settings if not explicitly provided
|
||||
if (newConfig.remoteConfig && config.remoteConfig) {
|
||||
// Make sure isRemote setting is preserved if not explicitly set
|
||||
if (req.body.remoteConfig?.isRemote === undefined) {
|
||||
newConfig.remoteConfig.isRemote = config.remoteConfig.isRemote;
|
||||
}
|
||||
|
||||
// Preserve directory mappings if not provided
|
||||
if (!req.body.remoteConfig?.directoryMapping && config.remoteConfig.directoryMapping) {
|
||||
newConfig.remoteConfig.directoryMapping = { ...config.remoteConfig.directoryMapping };
|
||||
}
|
||||
}
|
||||
|
||||
// Keep user passwords
|
||||
|
Loading…
x
Reference in New Issue
Block a user