mirror of
https://github.com/StarFleetCPTN/GoMFT.git
synced 2026-09-08 15:41:20 +02:00
@@ -27,7 +27,7 @@ func getInitialData(config *db.TransferConfig) string {
|
|||||||
sourceType := "local"
|
sourceType := "local"
|
||||||
sourcePath := ""
|
sourcePath := ""
|
||||||
sourceHost := ""
|
sourceHost := ""
|
||||||
sourcePort := 22
|
sourcePort := 0 // Initialize to 0 to trigger default setting
|
||||||
sourceUser := ""
|
sourceUser := ""
|
||||||
sourcePassword := ""
|
sourcePassword := ""
|
||||||
sourceKeyFile := ""
|
sourceKeyFile := ""
|
||||||
@@ -55,7 +55,7 @@ func getInitialData(config *db.TransferConfig) string {
|
|||||||
destinationType := "local"
|
destinationType := "local"
|
||||||
destinationPath := ""
|
destinationPath := ""
|
||||||
destHost := ""
|
destHost := ""
|
||||||
destPort := 22
|
destPort := 0 // Initialize to 0 to trigger default setting
|
||||||
destUser := ""
|
destUser := ""
|
||||||
destPassword := ""
|
destPassword := ""
|
||||||
destKeyFile := ""
|
destKeyFile := ""
|
||||||
@@ -386,11 +386,41 @@ templ ConfigForm(ctx context.Context, data ConfigFormData) {
|
|||||||
// Ensure initial form state displays correctly on load
|
// Ensure initial form state displays correctly on load
|
||||||
sourceType = sourceType || 'local';
|
sourceType = sourceType || 'local';
|
||||||
destinationType = destinationType || 'local';
|
destinationType = destinationType || 'local';
|
||||||
sourcePort = sourcePort || 22;
|
|
||||||
destPort = destPort || 22;
|
// Set default ports based on connection type
|
||||||
|
if (sourcePort === 0 || !sourcePort) {
|
||||||
|
if (sourceType === 'sftp') {
|
||||||
|
sourcePort = 22;
|
||||||
|
} else if (sourceType === 'ftp') {
|
||||||
|
sourcePort = 21;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (destPort === 0 || !destPort) {
|
||||||
|
if (destinationType === 'sftp') {
|
||||||
|
destPort = 22;
|
||||||
|
} else if (destinationType === 'ftp') {
|
||||||
|
destPort = 21;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize command requirements
|
// Initialize command requirements
|
||||||
updateCommandRequirements();
|
updateCommandRequirements();
|
||||||
})"
|
})"
|
||||||
|
x-effect="if (sourceType === 'sftp' && (sourcePort === 0 || sourcePort === 21)) {
|
||||||
|
sourcePort = 22;
|
||||||
|
console.log('Updating source port to 22 for SFTP');
|
||||||
|
} else if (sourceType === 'ftp' && (sourcePort === 0 || sourcePort === 22)) {
|
||||||
|
sourcePort = 21;
|
||||||
|
console.log('Updating source port to 21 for FTP');
|
||||||
|
}"
|
||||||
|
x-effect="if (destinationType === 'sftp' && (destPort === 0 || destPort === 21)) {
|
||||||
|
destPort = 22;
|
||||||
|
console.log('Updating destination port to 22 for SFTP');
|
||||||
|
} else if (destinationType === 'ftp' && (destPort === 0 || destPort === 22)) {
|
||||||
|
destPort = 21;
|
||||||
|
console.log('Updating destination port to 21 for FTP');
|
||||||
|
}"
|
||||||
>
|
>
|
||||||
|
|
||||||
<!-- Configuration Details Section -->
|
<!-- Configuration Details Section -->
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ templ FTPDestinationForm() {
|
|||||||
</div>
|
</div>
|
||||||
<input type="number" id="dest_port" name="dest_port" x-model="destPort"
|
<input type="number" id="dest_port" name="dest_port" x-model="destPort"
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="21" min="1" max="65535" />
|
placeholder="21" min="1" max="65535"
|
||||||
|
x-init="if (!destPort || destPort === 0) destPort = 21"
|
||||||
|
x-effect="if (destinationType === 'ftp' && (destPort === 0 || destPort === 22)) destPort = 21" />
|
||||||
</div>
|
</div>
|
||||||
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">FTP port number (default: 21)</p>
|
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">FTP port number (default: 21)</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ templ SFTPDestinationForm() {
|
|||||||
</div>
|
</div>
|
||||||
<input type="number" id="dest_port" name="dest_port" x-model="destPort"
|
<input type="number" id="dest_port" name="dest_port" x-model="destPort"
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="22" min="1" max="65535" />
|
placeholder="22" min="1" max="65535" x-init="if (!destPort || destPort === 0) destPort = 22" />
|
||||||
</div>
|
</div>
|
||||||
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">SFTP port number (default: 22)</p>
|
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">SFTP port number (default: 22)</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -74,7 +74,7 @@ templ SFTPDestinationForm() {
|
|||||||
<div class="absolute inset-y-0 start-0 flex items-center ps-3.5 pointer-events-none">
|
<div class="absolute inset-y-0 start-0 flex items-center ps-3.5 pointer-events-none">
|
||||||
<i class="fas fa-key text-gray-400 dark:text-gray-500"></i>
|
<i class="fas fa-key text-gray-400 dark:text-gray-500"></i>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" id="dest_key_file" name="dest_key_file" x-model="destinationKeyFile"
|
<input type="text" id="dest_key_file" name="dest_key_file" x-model="destKeyFile"
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="/path/to/id_rsa" x-bind:required="destAuthType === 'key'" />
|
placeholder="/path/to/id_rsa" x-bind:required="destAuthType === 'key'" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ templ FTPSourceForm() {
|
|||||||
</div>
|
</div>
|
||||||
<input type="number" id="source_port" name="source_port" x-model="sourcePort"
|
<input type="number" id="source_port" name="source_port" x-model="sourcePort"
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="21" min="1" max="65535" />
|
placeholder="21" min="1" max="65535" value="21"/>
|
||||||
</div>
|
</div>
|
||||||
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">FTP port number (default: 21)</p>
|
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">FTP port number (default: 21)</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -637,6 +637,7 @@ func (db *DB) GenerateRcloneConfig(config *TransferConfig) error {
|
|||||||
"host", config.SourceHost,
|
"host", config.SourceHost,
|
||||||
"user", config.SourceUser,
|
"user", config.SourceUser,
|
||||||
"pass", config.SourcePassword,
|
"pass", config.SourcePassword,
|
||||||
|
"port", fmt.Sprintf("%d", config.SourcePort),
|
||||||
"--non-interactive",
|
"--non-interactive",
|
||||||
"--config", configPath,
|
"--config", configPath,
|
||||||
"--log-level", "ERROR",
|
"--log-level", "ERROR",
|
||||||
@@ -860,6 +861,7 @@ func (db *DB) GenerateRcloneConfig(config *TransferConfig) error {
|
|||||||
args := []string{
|
args := []string{
|
||||||
"config", "create", destName, "ftp",
|
"config", "create", destName, "ftp",
|
||||||
"host", config.DestHost,
|
"host", config.DestHost,
|
||||||
|
"port", fmt.Sprintf("%d", config.DestPort),
|
||||||
"user", config.DestUser,
|
"user", config.DestUser,
|
||||||
"pass", config.DestPassword,
|
"pass", config.DestPassword,
|
||||||
"--non-interactive",
|
"--non-interactive",
|
||||||
|
|||||||
Reference in New Issue
Block a user