reverse-ssh 0.1.0

A Rust library for creating reverse SSH tunnels with automatic URL capture from services like localhost.run
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
# Contributing to reverse-ssh

Thank you for your interest in contributing to reverse-ssh! This document provides guidelines and instructions for contributing.

## Table of Contents

- [Code of Conduct]#code-of-conduct
- [Getting Started]#getting-started
- [How to Contribute]#how-to-contribute
- [Development Setup]#development-setup
- [Testing]#testing
- [Code Style]#code-style
- [Submitting Changes]#submitting-changes
- [Reporting Bugs]#reporting-bugs
- [Suggesting Features]#suggesting-features

## Code of Conduct

Be respectful, inclusive, and constructive in all interactions.

## Getting Started

1. Fork the repository on GitHub
2. Clone your fork locally
3. Set up the development environment
4. Create a new branch for your changes
5. Make your changes
6. Test thoroughly
7. Submit a pull request

## How to Contribute

### Types of Contributions

We welcome:
- ๐Ÿ› Bug fixes
- โœจ New features
- ๐Ÿ“ Documentation improvements
- ๐ŸŽจ Code quality improvements
- ๐Ÿงช Additional tests
- ๐ŸŒ Translation/internationalization
- ๐Ÿ’ก Feature suggestions

### Development Setup

```bash
# Clone your fork
git clone https://github.com/YOUR_USERNAME/rrp.git
cd rrp

# Build the project
cargo build

# Run tests
cargo test

# Run examples
cargo run --example localhost_run
```

### Prerequisites

- Rust 1.87+ (nightly)
- Git
- SSH client (for testing)
- Optionally: An SSH server for testing

## Testing

### Running Tests

```bash
# Run all tests
cargo test

# Run specific test
cargo test test_config_creation

# Run with debug output
RUST_LOG=debug cargo test
```

### Testing Examples

```bash
# Test localhost_run example
cargo run --example localhost_run

# Test simple_server
cargo run --example simple_server

# Test with custom SSH server
export SSH_HOST=your-server.com
export SSH_USER=your-username
export SSH_KEY=~/.ssh/id_rsa
cargo run --example local_test
```

### Adding Tests

When adding new functionality:
1. Write unit tests in the same file as the code
2. Write integration tests in `tests/` directory
3. Add examples if the feature is user-facing
4. Update documentation

Example test:
```rust
#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_new_feature() {
        // Your test here
        assert_eq!(2 + 2, 4);
    }
}
```

## Code Style

### Rust Guidelines

Follow the official [Rust Style Guide](https://doc.rust-lang.org/nightly/style-guide/):

```bash
# Format code
cargo fmt

# Check for common mistakes
cargo clippy

# Check everything
cargo fmt && cargo clippy && cargo test
```

### Code Conventions

- Use meaningful variable names
- Add comments for complex logic
- Keep functions small and focused
- Use `Result` and `?` for error handling
- Prefer `async/await` over callbacks
- Use `tracing` for logging, not `println!`

### Documentation

- Add doc comments to public functions
- Include examples in doc comments
- Update README.md for user-facing changes
- Keep CHANGELOG.md up to date

Example:
```rust
/// Connects to the SSH server and authenticates.
///
/// # Arguments
///
/// * `tx` - Channel for forwarding connections
/// * `message_tx` - Channel for server messages
///
/// # Example
///
/// ```no_run
/// let mut client = ReverseSshClient::new(config);
/// client.connect(tx, message_tx).await?;
/// ```
///
/// # Errors
///
/// Returns an error if connection or authentication fails.
pub async fn connect(&mut self, ...) -> Result<()> {
    // Implementation
}
```

## Submitting Changes

### Pull Request Process

1. **Update your fork**
   ```bash
   git remote add upstream https://github.com/aovestdipaperino/rrp.git
   git fetch upstream
   git rebase upstream/main
   ```

2. **Create a feature branch**
   ```bash
   git checkout -b feature/your-feature-name
   ```

3. **Make your changes**
   - Write clean, documented code
   - Add tests
   - Update documentation
   - Follow code style guidelines

4. **Commit your changes**
   ```bash
   git add .
   git commit -m "Add feature: your feature description"
   ```

   Good commit message format:
   ```
   Add feature: Brief description (50 chars or less)

   More detailed explanation if needed. Wrap at 72 characters.

   - Bullet points are okay
   - Include context and reasoning
   - Reference issues: Fixes #123
   ```

5. **Push to your fork**
   ```bash
   git push origin feature/your-feature-name
   ```

6. **Create a Pull Request**
   - Go to GitHub and create a PR
   - Fill out the PR template
   - Link related issues
   - Add screenshots for UI changes

### PR Checklist

Before submitting:
- [ ] Code compiles without warnings
- [ ] All tests pass
- [ ] Code is formatted (`cargo fmt`)
- [ ] No clippy warnings (`cargo clippy`)
- [ ] Documentation updated
- [ ] CHANGELOG.md updated
- [ ] Examples work if applicable
- [ ] Commit messages are clear

### Review Process

1. Maintainers will review your PR
2. Address any feedback
3. Once approved, your PR will be merged
4. Your contribution will be in the next release!

## Reporting Bugs

### Before Submitting

1. Check if the bug is already reported
2. Try the latest version
3. Gather information about the bug

### Bug Report Template

```markdown
**Description**
A clear description of the bug.

**To Reproduce**
Steps to reproduce:
1. Run `cargo run --example localhost_run`
2. See error

**Expected Behavior**
What you expected to happen.

**Actual Behavior**
What actually happened.

**Environment**
- OS: [e.g., Ubuntu 22.04]
- Rust version: [e.g., 1.87.0]
- reverse-ssh version: [e.g., 0.1.0]

**Logs**
```
Paste debug logs here (RUST_LOG=debug)
```

**Additional Context**
Any other relevant information.
```

## Suggesting Features

### Feature Request Template

```markdown
**Is your feature related to a problem?**
A clear description of the problem.

**Describe the solution**
How you'd like it to work.

**Alternatives considered**
Other solutions you've thought about.

**Additional context**
Mockups, examples, use cases.
```

### Feature Discussion

1. Open an issue to discuss the feature
2. Get feedback from maintainers
3. If approved, implement it following these guidelines
4. Submit a PR

## Areas Needing Help

We especially welcome contributions in:

- ๐Ÿงช **Testing**: More tests and edge cases
- ๐Ÿ“ **Documentation**: Improving examples and guides
- ๐ŸŒ **Compatibility**: Testing on different platforms
- ๐Ÿš€ **Performance**: Optimization improvements
- ๐Ÿ”’ **Security**: Security audits and improvements
- ๐ŸŽจ **Examples**: More real-world use cases
- ๐Ÿ› **Bug Fixes**: Fixing reported issues

## Development Tips

### Debugging

```bash
# Enable debug logging
RUST_LOG=debug cargo run --example localhost_run

# Enable trace logging (very verbose)
RUST_LOG=trace cargo run --example localhost_run

# Run with backtrace
RUST_BACKTRACE=1 cargo run --example localhost_run
```

### Testing SSH Connections

```bash
# Test with standard SSH first
ssh -R 80:localhost:8080 localhost.run

# Compare with library behavior
RUST_LOG=debug cargo run --example localhost_run
```

### Benchmarking

```bash
# Run benchmarks (if available)
cargo bench

# Profile with flamegraph
cargo install flamegraph
cargo flamegraph --example localhost_run
```

## Documentation Guidelines

### README.md

- Keep it concise
- Include quick start
- Link to detailed docs
- Add badges

### Code Comments

```rust
// Good: Explains why
// Use empty string for bind address because localhost.run expects it
handle.tcpip_forward("", port).await?;

// Bad: Explains what (obvious from code)
// Call tcpip_forward with empty string and port
handle.tcpip_forward("", port).await?;
```

### Examples

- Keep examples simple and focused
- Add comments explaining each step
- Include error handling
- Show expected output

## Release Process

Maintainers follow this process for releases:

1. Update version in `Cargo.toml`
2. Update `CHANGELOG.md`
3. Run all tests
4. Create git tag
5. Publish to crates.io
6. Create GitHub release

## Getting Help

- ๐Ÿ’ฌ Open an issue for questions
- ๐Ÿ“ง Email: enzinol@gmail.com
- ๐Ÿ“– Check the documentation
- ๐Ÿ” Search existing issues

## Recognition

Contributors will be:
- Listed in CHANGELOG.md
- Credited in release notes
- Mentioned in README.md (for significant contributions)

## License

By contributing, you agree that your contributions will be licensed under the same license as the project (MIT OR Apache-2.0).

---

Thank you for contributing to reverse-ssh! ๐ŸŽ‰