clean up add lxc

This commit is contained in:
2023-11-13 23:41:42 -07:00
parent e6cc863cf9
commit b9db9bc2ef
3 changed files with 55 additions and 169 deletions

View File

@@ -1,86 +0,0 @@
# socks examples
## Example for SOCKS 'bind' command
The bind command tells the SOCKS proxy server to bind and listen on a new TCP port for an incoming connection. It communicates the newly opened port back to the origin client. Once a incoming connection is accepted by the SOCKS proxy server it then communicates the remote host that connected to the SOCKS proxy back through the same initial connection via the origin client.
This can be used for things such as FTP clients which require incoming TCP connections, etc.
**Connection Steps**
1. Client -(bind)-> Proxy (Tells the proxy to bind to a new port)
2. Client <-(port)- Proxy (Tells the origin client which port it opened)
3. Client2 --> Proxy (Other client connects to the proxy on this port)
4. Client <--(client2's host info) (Proxy tells the origin client who connected to it)
5. Original connection to the proxy is now a full TCP stream between client (you) and client2.
6. Client <--> Proxy <--> Client2
## Usage
The 'bind' command can only be used by creating a new SocksClient instance and listening for 'bound' and 'established' events.
```typescript
import { SocksClient, SocksClientOptions } from 'socks';
const options: SocksClientOptions = {
proxy: {
host: '104.131.124.203',
port: 1081,
type: 5
},
// This should be the ip and port of the expected client that will connect to the SOCKS proxy server on the newly bound port.
// Most SOCKS servers accept 0.0.0.0 as a wildcard address to accept any client.
destination: {
host: '0.0.0.0',
port: 0
},
command: 'bind'
};
const client = new SocksClient(options);
// This event is fired when the SOCKS server has started listening on a new port for incoming connections.
client.on('bound', (info) => {
console.log(info);
/*
{
socket: <Socket ...>,
remoteHost: { // This is the remote ip and port of the SOCKS proxy that is now accepting incoming connections.
host: '104.131.124.203',
port: 49928
}
}
*/
});
// This event is fired when the SOCKS server has accepted an incoming connection on the newly bound port.
client.on('established', (info) => {
console.log(info);
/*
{
socket: <Socket ...>,
remoteHost: { // This is the remote ip and port that connected to the SOCKS proxy on the newly bound port.
host: '1.2.3.4',
port: 58232
}
}
*/
// At this point info.socket is a regular net.Socket TCP connection between client and client2 (1.2.3.4) (the client which connected to the proxy on the newly bound port.)
console.log(info.socket);
// <Socket ...> (this is a raw net.Socket that is established to the destination host through the given proxy servers)
});
// SOCKS proxy failed to bind.
client.on('error', () => {
// Handle errors
});
// Start connection
client.connect();
```

View File

@@ -1,83 +0,0 @@
# socks examples
## Example for SOCKS 'bind' command
The bind command tells the SOCKS proxy server to bind and listen on a new TCP port for an incoming connection. It communicates the newly opened port back to the origin client. Once a incoming connection is accepted by the SOCKS proxy server it then communicates the remote host that connected to the SOCKS proxy back through the same initial connection via the origin client.
This can be used for things such as FTP clients which require incoming TCP connections, etc.
**Connection Steps**
1. Client -(bind)-> Proxy (Tells the proxy to bind to a new port)
2. Client <-(port)- Proxy (Tells the origin client which port it opened)
3. Client2 --> Proxy (Other client connects to the proxy on this port)
4. Client <--(client2's host info) (Proxy tells the origin client who connected to it)
5. Original connection to the proxy is now a full TCP stream between client (you) and client2.
6. Client <--> Proxy <--> Client2
## Usage
The 'bind' command can only be used by creating a new SocksClient instance and listening for 'bound' and 'established' events.
```typescript
const SocksClient = require('socks').SocksClient;
const options = {
proxy: {
host: '104.131.124.203',
port: 1081,
type: 5
},
// This should be the ip and port of the expected client that will connect to the SOCKS proxy server on the newly bound port.
// Most SOCKS servers accept 0.0.0.0 as a wildcard address to accept any client.
destination: {
host: '0.0.0.0',
port: 0
},
command: 'bind'
};
const client = new SocksClient(options);
// This event is fired when the SOCKS server has started listening on a new port for incoming connections.
client.on('bound', (info) => {
console.log(info);
/*
{
socket: <Socket ...>,
remoteHost: { // This is the remote ip and port of the SOCKS proxy that is now accepting incoming connections.
host: '104.131.124.203',
port: 49928
}
}
*/
});
// This event is fired when the SOCKS server has accepted an incoming connection on the newly bound port.
client.on('established', (info) => {
console.log(info);
/*
{
socket: <Socket ...>,
remoteHost: { // This is the remote ip and port that connected to the SOCKS proxy on the newly bound port.
host: '1.2.3.4',
port: 58232
}
}
*/
// At this point info.socket is a regular net.Socket TCP connection between client and client2 (1.2.3.4) (the client which connected to the proxy on the newly bound port.)
console.log(info.socket);
// <Socket ...> (this is a raw net.Socket that is established to the destination host through the given proxy servers)
});
// SOCKS proxy failed to bind.
client.on('error', () => {
// Handle errors
});
```

55
docs/tech_docs/lxc.md Normal file
View File

@@ -0,0 +1,55 @@
# LXC CLI Cheatsheet
## Container Management
- _Usage:_ Useful for day-to-day container management tasks like checking container status, executing commands inside containers, and getting detailed information.
- `lxc list -c n,s,4,image.description:image`
_Description:_ Lists containers with specific columns like name, state, IPv4 address, and image description.
- `lxc info <container-name>`
_Description:_ Displays detailed information about a specific container.
_Example:_ `lxc info mycontainer`
- `lxc exec <container-name> -- <command>`
_Description:_ Executes a command inside the specified container.
_Example:_ `lxc exec mycontainer -- bash`
## Image Management
- _Usage:_ Important for understanding what images are available and for selecting the right image for container deployment.
- `lxc image list`
_Description:_ Lists all available images.
- `lxc image alias list <repository>: <tag>`
_Description:_ Lists all aliases for an image in a repository.
_Example:_ `lxc image alias list ubuntu: '20.04'`
## Networking
- _Usage:_ Essential for setting up and troubleshooting container networking, ensuring containers can communicate with each other and the outside world.
- `lxc network list`
_Description:_ Lists all networks.
- `lxc network show <network-name>`
_Description:_ Shows detailed information about a specific network.
_Example:_ `lxc network show lxdbr0`
## Advanced Container Operations
- _Usage:_ Advanced features that allow for more complex container management, like cloning containers, and managing container states and backups.
- `lxc launch <image-name>`
_Description:_ Launches a new container from the specified image.
_Examples:_ `lxc launch ubuntu:20.04`, `lxc launch images:alpine/3.13`
- `lxc copy <source-container> <destination-container>`
_Description:_ Copies a container to a new container.
- `lxc snapshot <container-name>`
_Description:_ Creates a snapshot of a container.
- `lxc restore <container-name> <snapshot-name>`
_Description:_ Restores a container from a specified snapshot.
## File Management
- _Usage:_ Useful for deploying configuration files or scripts inside containers.
- `lxc file push <source-path> <container-name>/<destination-path>`
_Description:_ Pushes a file from the host to the container.
## Troubleshooting and Help
- _Usage:_ Crucial for diagnosing and resolving issues with containers and processes.
- `lxc --help`
_Description:_ Displays help for LXC commands.
- `ps -ef | grep <process-name>`
_Description:_ Finds processes related to a specific name, useful for troubleshooting.
_Example:_ `ps -ef | grep dnsmasq`
> **Note:** Replace placeholders like `<container-name>`, `<network-name>`, and `<image-name>` with actual names when using the commands.