Metadata-Version: 2.1
Name: nkosi
Version: 3.2
Summary: A network tool for device discovery and communication
Author-email: Nandhan K <developer.nandhank@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/Nandhan-KA/nkosi
Project-URL: Documentation, https://github.com/Nandhan-KA/nkosi#readme
Project-URL: Repository, https://github.com/Nandhan-KA/nkosi
Project-URL: BugTracker, https://github.com/Nandhan-KA/nkosi/issues
Keywords: Network Discovery,OSI Model Visualizer,Network Tools,TCP/UDP Communication
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Environment :: Win32 (MS Windows)
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: rich>=13.0.0
Requires-Dist: ipaddress>=1.0.0
Requires-Dist: netifaces>=0.11.0
Requires-Dist: python-nmap>=0.7.1
Requires-Dist: scapy>=2.5.0
Requires-Dist: psutil>=5.9.0
Requires-Dist: requests>=2.31.0
Provides-Extra: linux
Requires-Dist: arp-scan; extra == "linux"
Requires-Dist: tcpdump; extra == "linux"
Requires-Dist: nmap; extra == "linux"
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: black>=21.5b2; extra == "dev"
Requires-Dist: isort>=5.8.0; extra == "dev"
Requires-Dist: mypy>=0.812; extra == "dev"
Requires-Dist: pylint>=2.8.2; extra == "dev"

# Nkosi

[![Python Version](https://img.shields.io/badge/python-3.6%2B-blue.svg)](https://www.python.org/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Nkosi is a Python package for network device discovery and communication. It provides tools to:

- Discover devices on your local network using ARP
- Establish TCP/UDP communication channels
- Create network servers and clients with minimal code
- Send and receive messages between devices

## Features

- **Device Discovery**: Find all devices on your local network using ARP scanning
- **TCP Communication**: Full-featured TCP server and client implementations
- **UDP Communication**: UDP server and client with broadcast support
- **Easy to Use**: Simple API for common networking tasks
- **Cross-platform**: Works on Windows, macOS, and Linux

## Installation

```bash
pip install nkosi
```

## Quick Start

### Discovering Devices on Your Network

```python
from nkosi import discover_devices

devices = discover_devices()
for device in devices:
    print(f"IP: {device['ip']}, MAC: {device['mac']}, Hostname: {device['hostname']}")
```

### Creating a TCP Server

```python
from nkosi import TCPServer

def on_message_received(message, client_address):
    print(f"Received from {client_address}: {message}")

server = TCPServer(host='0.0.0.0', port=5000)
server.start(callback=on_message_received)

# Keep the server running
input("Press Enter to stop the server...")
server.stop()
```

### Creating a TCP Client

```python
from nkosi import TCPClient

def on_message_received(message):
    print(f"Received from server: {message}")

client = TCPClient(host='localhost', port=5000)
if client.connect(callback=on_message_received):
    client.send({"type": "greeting", "message": "Hello, server!"})
    
    # Keep the client running
    input("Press Enter to disconnect...")
    client.disconnect()
```

### Creating a UDP Server

```python
from nkosi import UDPServer

def on_message_received(message, client_address):
    print(f"Received from {client_address}: {message}")

server = UDPServer(host='0.0.0.0', port=5001)
server.start(callback=on_message_received)

# Keep the server running
input("Press Enter to stop the server...")
server.stop()
```

### Creating a UDP Client

```python
from nkosi import UDPClient

def on_message_received(message, sender_address):
    print(f"Received from {sender_address}: {message}")

client = UDPClient(host='localhost', port=5001)
if client.start(callback=on_message_received):
    client.send({"type": "greeting", "message": "Hello, server!"})
    
    # Keep the client running
    input("Press Enter to stop the client...")
    client.stop()
```

## Command Line Interface

Nkosi also provides a simple command-line interface for common tasks.

### Discover Devices

```bash
nkosi-discover
```

### Send a Message

```bash
# Send a message to a TCP server
nkosi-send --host localhost --port 5000 --message "Hello, server!" --protocol tcp

# Send a message to a UDP server
nkosi-send --host localhost --port 5001 --message "Hello, server!" --protocol udp
```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.
