|
| 1 | + |
| 2 | +--- |
| 3 | + |
| 4 | +# Contributing to xpscan 🚀 |
| 5 | + |
| 6 | +First of all, thank you for showing interest in contributing to **xpscan**! Community contributions are what make open-source tools robust and reliable. |
| 7 | + |
| 8 | +Whether you are fixing a bug, improving documentation, or adding a new feature, your help is appreciated. Please take a moment to review this guide to ensure a smooth contribution process. |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +## 🏗️ Project Architecture Overview |
| 13 | + |
| 14 | +Before you dive into the code, it helps to understand how the project is organized. We follow a modular design to keep the networking logic separate from the file management. |
| 15 | + |
| 16 | +* **Scanner:** Handles the networking logic (non-blocking sockets). |
| 17 | +* **Exporter:** Handles saving results to the disk. |
| 18 | +* **Common:** Shared data structures (like the `PortResult` struct). |
| 19 | +* **Tests:** Unit tests using CRITERION to ensure stability. |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## 🛠️ How to Get Started |
| 24 | + |
| 25 | +### 1. Prerequisites |
| 26 | + |
| 27 | +You will need the following tools on your machine: |
| 28 | + |
| 29 | +* **C++ Compiler** (supporting C++17 or later) |
| 30 | +* **CMake** (version 3.10+) |
| 31 | +* **Git** |
| 32 | +* **Criterion** (usually fetched automatically via CMake) |
| 33 | + |
| 34 | +### 2. Setting Up Your Local Environment |
| 35 | + |
| 36 | +1. **Fork** the repository on GitHub. |
| 37 | +2. **Clone** your fork locally: |
| 38 | +```bash |
| 39 | +git clone https://github.com/your-username/xpscan.git |
| 40 | +cd xpscan |
| 41 | + |
| 42 | +``` |
| 43 | + |
| 44 | + |
| 45 | +3. **Build** the project to make sure everything is working: |
| 46 | +```bash |
| 47 | +mkdir build && cd build |
| 48 | +cmake .. |
| 49 | +make |
| 50 | + |
| 51 | +``` |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +## 🧪 Development Rules |
| 58 | + |
| 59 | +### 1. Writing Tests |
| 60 | + |
| 61 | +We use **Mocking** to test the scanner without actually hitting the network and to test the exporter without actually writing to the disk. |
| 62 | + |
| 63 | +* If you add a new feature, please add a test in `tests/ScannerTest.cpp`. |
| 64 | +* Run tests using: `ctest` or `./xpscan_tests`. |
| 65 | + |
| 66 | +### 2. Performance First |
| 67 | + |
| 68 | +`xpscan` is designed to be fast. |
| 69 | + |
| 70 | +* Avoid blocking calls. |
| 71 | +* Always use the `O_NONBLOCK` flag for new networking features. |
| 72 | +* Respect the 200ms timeout window to prevent the tool from "hanging." |
| 73 | + |
| 74 | +### 3. Code Style |
| 75 | + |
| 76 | +* Use descriptive variable names. |
| 77 | +* Comment complex logic, especially around bitwise operations or socket configurations. |
| 78 | +* Keep functions small and focused on a single task. |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +## 📬 Submitting Your Changes |
| 83 | + |
| 84 | +### Step 1: Create a Branch |
| 85 | + |
| 86 | +Always create a new branch for your work: |
| 87 | + |
| 88 | +```bash |
| 89 | +git checkout -b feature/your-feature-name |
| 90 | + |
| 91 | +``` |
| 92 | + |
| 93 | +### Step 2: Commit Your Changes |
| 94 | + |
| 95 | +Write clear, concise commit messages: |
| 96 | + |
| 97 | +* `feat: add XML export support` |
| 98 | +* `fix: resolve memory leak in scanner` |
| 99 | +* `docs: update installation instructions` |
| 100 | + |
| 101 | +### Step 3: Push and Open a Pull Request (PR) |
| 102 | + |
| 103 | +1. Push your branch to your fork: `git push origin feature/your-feature-name`. |
| 104 | +2. Open a Pull Request on the main repository. |
| 105 | +3. Fill out the **PR Template** provided (it will pop up automatically). |
| 106 | +4. Wait for a maintainer to review your code! |
| 107 | + |
| 108 | +--- |
| 109 | + |
| 110 | +## 📜 Code of Conduct |
| 111 | + |
| 112 | +By participating in this project, you agree to maintain a respectful and inclusive environment. Please be kind to other contributors! |
| 113 | + |
| 114 | +--- |
0 commit comments