update
This commit is contained in:
parent
dd89a3c577
commit
5bd27c069e
@ -1985,9 +1985,9 @@ func main() {
|
||||
```
|
||||
|
||||
#### How It Works:
|
||||
1. **Fetch Hostname**: The script retrieves the server's hostname using `os.Hostname()`, which is later sent as part of the request to identify the sender.
|
||||
2. **Build Message**: The message is constructed from command-line arguments and passed into the API request.
|
||||
3. **Send Notification**: The client sends a GET request to the server, including the API key, hostname, and message content.
|
||||
**Fetch Hostname**: The script retrieves the server's hostname using `os.Hostname()`, which is later sent as part of the request to identify the sender.
|
||||
**Build Message**: The message is constructed from command-line arguments and passed into the API request.
|
||||
**Send Notification**: The client sends a GET request to the server, including the API key, hostname, and message content.
|
||||
|
||||
### Use Cases
|
||||
|
||||
@ -2050,11 +2050,11 @@ sudo chmod +x /usr/bin/sshup-all
|
||||
```
|
||||
|
||||
#### How it works:
|
||||
1. **User Prompts**: The script prompts the user for their `SSHID` and `KEY`, which are necessary for identifying the container and validating the upload.
|
||||
2. **Creating Upload Scripts**:
|
||||
**User Prompts**: The script prompts the user for their `SSHID` and `KEY`, which are necessary for identifying the container and validating the upload.
|
||||
**Creating Upload Scripts**:
|
||||
- `sshup`: A command-line utility for uploading a single file.
|
||||
- `sshup-all`: A utility for uploading all files in the current directory.
|
||||
3. **Permissions**: The scripts are saved under `/usr/bin/` and made executable, allowing users to run the uploader from anywhere on their system.
|
||||
**Permissions**: The scripts are saved under `/usr/bin/` and made executable, allowing users to run the uploader from anywhere on their system.
|
||||
|
||||
Once installed, users can upload files using the command `sshup <filename>` and receive an output like:
|
||||
|
||||
@ -2093,10 +2093,10 @@ const connection = mysql.createConnection({
|
||||
```
|
||||
|
||||
#### Key Components:
|
||||
1. **Express.js**: Handles incoming HTTP requests and manages file uploads.
|
||||
2. **multer**: A middleware for handling file uploads.
|
||||
3. **cmd-promise**: Used to execute system commands, such as copying the file to the Docker container.
|
||||
4. **MySQL Database**: Stores user information, including SSH IDs and keys, to verify upload requests.
|
||||
**Express.js**: Handles incoming HTTP requests and manages file uploads.
|
||||
**multer**: A middleware for handling file uploads.
|
||||
**cmd-promise**: Used to execute system commands, such as copying the file to the Docker container.
|
||||
**MySQL Database**: Stores user information, including SSH IDs and keys, to verify upload requests.
|
||||
|
||||
#### Upload Logic
|
||||
|
||||
@ -2143,11 +2143,11 @@ app.post('/', multer({ dest: "uploads/" }).single('myFile'), (req, res) => {
|
||||
```
|
||||
|
||||
#### Step-by-Step Process:
|
||||
1. **Receive File**: The file is uploaded to a temporary directory.
|
||||
2. **Verify Key**: The server checks the provided key to ensure the upload is authorized.
|
||||
3. **Check Container**: The server checks if the container exists and is running.
|
||||
4. **Copy File**: If everything checks out, the file is copied to the user’s container using `docker cp`.
|
||||
5. **Cleanup**: The temporary file is removed from the server after the upload is complete.
|
||||
**Receive File**: The file is uploaded to a temporary directory.
|
||||
**Verify Key**: The server checks the provided key to ensure the upload is authorized.
|
||||
**Check Container**: The server checks if the container exists and is running.
|
||||
**Copy File**: If everything checks out, the file is copied to the user’s container using `docker cp`.
|
||||
**Cleanup**: The temporary file is removed from the server after the upload is complete.
|
||||
|
||||
#### Example Output:
|
||||
```bash
|
||||
|
Loading…
Reference in New Issue
Block a user