-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
timer repair, reset counter when uploading duplicates, fix port dupli…
…cation issues
- Loading branch information
Showing
6 changed files
with
66 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"components":{"schemas":{"File":{"properties":{"downloadCount":{"format":"int64","type":"integer"},"downloadLimit":{"format":"int64","type":"integer"},"error":{"type":"string"},"expireTime":{"format":"date-time","type":"string"},"fileCount":{"type":"integer"},"files":{"items":{"properties":{"downloadUrl":{"type":"string"},"fileName":{"type":"string"},"fileSize":{"format":"int64","type":"integer"}},"type":"object"},"type":"array"},"folderId":{"type":"string"},"isHidden":{"type":"boolean"},"message":{"type":"string"},"uploadDate":{"format":"date-time","type":"string"}},"type":"object"},"Files":{"properties":{"error":{"type":"string"},"list":{"items":{"properties":{"downloadCount":{"format":"int64","type":"integer"},"downloadLimit":{"format":"int64","type":"integer"},"expireTime":{"format":"date-time","type":"string"},"fileCount":{"type":"integer"},"files":{"items":{"properties":{"downloadUrl":{"type":"string"},"fileName":{"type":"string"},"fileSize":{"format":"int64","type":"integer"}},"type":"object"},"type":"array"},"folderId":{"type":"string"},"isHidden":{"type":"boolean"},"uploadDate":{"format":"date-time","type":"string"}},"type":"object"},"type":"array"},"message":{"type":"string"}},"type":"object"},"string":{"type":"string"},"unknown-interface":{}}},"info":{"description":"OpenAPI","title":"OpenAPI","version":"0.0.1"},"openapi":"3.0.3","paths":{"/":{"get":{"description":"controller: main.main.func1","operationId":"GET /:func1","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/string"}}},"description":"OK"},"default":{"description":""}},"summary":"func1","tags":["default"]}},"/del/{id}":{"delete":{"description":"controller: github.com/tempfiles-Team/tempfiles-backend/controllers.FilesRessources.deleteFiles","operationId":"DELETE /del/{id}:deleteFiles","parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/File"}}},"description":"OK"},"default":{"description":""}},"summary":"deleteFiles","tags":["File"]}},"/dl/{id}/{name}":{"get":{"description":"controller: github.com/tempfiles-Team/tempfiles-backend/controllers.FilesRessources.downloadFile","operationId":"GET /dl/{id}/{name}:downloadFile","parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}},{"in":"path","name":"name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/unknown-interface"}}},"description":"OK"},"default":{"description":""}},"summary":"downloadFile"}},"/file/{id}":{"get":{"description":"controller: github.com/tempfiles-Team/tempfiles-backend/controllers.FilesRessources.getFiles","operationId":"GET /file/{id}:getFiles","parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/File"}}},"description":"OK"},"default":{"description":""}},"summary":"getFiles","tags":["File"]}},"/list":{"get":{"description":"controller: github.com/tempfiles-Team/tempfiles-backend/controllers.FilesRessources.getAllFiles","operationId":"GET /list:getAllFiles","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Files"}}},"description":"OK"},"default":{"description":""}},"summary":"getAllFiles","tags":["Files"]}},"/upload":{"post":{"description":"Upload files","operationId":"POST /upload:postFiles","parameters":[{"description":"Download limit","in":"header","name":"X-Download-Limit","schema":{"type":"string"}},{"description":"Time limit","in":"header","name":"X-Time-Limit","schema":{"type":"string"}},{"description":"Hidden","in":"header","name":"X-Hidden","schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/File"}}},"description":"OK"},"default":{"description":""}},"summary":"postFiles","tags":["File"]}},"/view/{id}/{name}":{"get":{"description":"controller: github.com/tempfiles-Team/tempfiles-backend/controllers.FilesRessources.ViewFile","operationId":"GET /view/{id}/{name}:ViewFile","parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}},{"in":"path","name":"name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/unknown-interface"}}},"description":"OK"},"default":{"description":""}},"summary":"ViewFile"}}}} | ||
{"components":{"schemas":{"File":{"properties":{"downloadCount":{"format":"int64","type":"integer"},"downloadLimit":{"format":"int64","type":"integer"},"error":{"type":"string"},"expireTime":{"format":"int64","type":"integer"},"fileCount":{"type":"integer"},"files":{"items":{"properties":{"downloadUrl":{"type":"string"},"fileName":{"type":"string"},"fileSize":{"format":"int64","type":"integer"}},"type":"object"},"type":"array"},"folderId":{"type":"string"},"isHidden":{"type":"boolean"},"message":{"type":"string"},"uploadDate":{"format":"date-time","type":"string"}},"type":"object"},"Files":{"properties":{"error":{"type":"string"},"list":{"items":{"properties":{"downloadCount":{"format":"int64","type":"integer"},"downloadLimit":{"format":"int64","type":"integer"},"expireTime":{"format":"int64","type":"integer"},"fileCount":{"type":"integer"},"files":{"items":{"properties":{"downloadUrl":{"type":"string"},"fileName":{"type":"string"},"fileSize":{"format":"int64","type":"integer"}},"type":"object"},"type":"array"},"folderId":{"type":"string"},"isHidden":{"type":"boolean"},"uploadDate":{"format":"date-time","type":"string"}},"type":"object"},"type":"array"},"message":{"type":"string"}},"type":"object"},"string":{"type":"string"},"unknown-interface":{}}},"info":{"description":"OpenAPI","title":"OpenAPI","version":"0.0.1"},"openapi":"3.0.3","paths":{"/":{"get":{"description":"controller: main.main.func1","operationId":"GET /:func1","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/string"}}},"description":"OK"},"default":{"description":""}},"summary":"func1","tags":["default"]}},"/del/{id}":{"delete":{"description":"controller: github.com/tempfiles-Team/tempfiles-backend/controllers.FilesRessources.deleteFiles","operationId":"DELETE /del/{id}:deleteFiles","parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/File"}}},"description":"OK"},"default":{"description":""}},"summary":"deleteFiles","tags":["File"]}},"/dl/{id}/{name}":{"get":{"description":"controller: github.com/tempfiles-Team/tempfiles-backend/controllers.FilesRessources.downloadFile","operationId":"GET /dl/{id}/{name}:downloadFile","parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}},{"in":"path","name":"name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/unknown-interface"}}},"description":"OK"},"default":{"description":""}},"summary":"downloadFile"}},"/file/{id}":{"get":{"description":"controller: github.com/tempfiles-Team/tempfiles-backend/controllers.FilesRessources.getFiles","operationId":"GET /file/{id}:getFiles","parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/File"}}},"description":"OK"},"default":{"description":""}},"summary":"getFiles","tags":["File"]}},"/list":{"get":{"description":"controller: github.com/tempfiles-Team/tempfiles-backend/controllers.FilesRessources.getAllFiles","operationId":"GET /list:getAllFiles","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Files"}}},"description":"OK"},"default":{"description":""}},"summary":"getAllFiles","tags":["Files"]}},"/upload":{"post":{"description":"Upload files","operationId":"POST /upload:postFiles","parameters":[{"description":"Download limit","in":"header","name":"X-Download-Limit","schema":{"type":"string"}},{"description":"Time limit","in":"header","name":"X-Time-Limit","schema":{"type":"string"}},{"description":"Hidden","in":"header","name":"X-Hidden","schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/File"}}},"description":"OK"},"default":{"description":""}},"summary":"postFiles","tags":["File"]}},"/view/{id}/{name}":{"get":{"description":"controller: github.com/tempfiles-Team/tempfiles-backend/controllers.FilesRessources.ViewFile","operationId":"GET /view/{id}/{name}:ViewFile","parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}},{"in":"path","name":"name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/unknown-interface"}}},"description":"OK"},"default":{"description":""}},"summary":"ViewFile"}}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package utils | ||
|
||
import ( | ||
"fmt" | ||
"net" | ||
"strconv" | ||
) | ||
|
||
func CheckPortAvailable(port string) string { | ||
// Parse the port number | ||
p, err := strconv.Atoi(port) | ||
if err != nil { | ||
return "" | ||
} | ||
|
||
// Check if the port is available | ||
addr, err := net.ResolveTCPAddr("tcp", fmt.Sprintf(":%d", p)) | ||
if err != nil { | ||
return "" | ||
} | ||
|
||
l, err := net.ListenTCP("tcp", addr) | ||
if err != nil { | ||
// If the port is not available, increment the port number and try again | ||
return CheckPortAvailable(fmt.Sprintf("%d", p+1)) | ||
} | ||
defer l.Close() | ||
|
||
// If the port is available, return it | ||
|
||
fmt.Println("Port is available:", port) | ||
return port | ||
} |