# Ku-proxy wiki

![](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)![](https://img.shields.io/gitlab/license/seeklay/ku.svg)![](https://tokei.rs/b1/gitlab/seeklay/ku)![](https://badgen.net/pypi/v/ku-proxy)![](https://img.shields.io/pypi/dw/ku-proxy?style=flat\&logo=pypi)![](https://gitlab.com/seeklay/ku/badges/main/pipeline.svg)![](https://gitlab.com/seeklay/ku/badges/main/coverage.svg)

## About

Ku is TCP main-in-the-middle proxy written in pure python3 on top of threading and select.\
Object orientated, functional, powerful.

## Links

* **Project git repository**: <https://gitlab.com/seeklay/ku>
* **PyPI**: [https://pypi.org/project/ku-proxy](https://pypi.org/project/ku-proxy/)
* **Author**: <https://gitlab.com/seeklay>
* **Code Examples**:[ https://gitlab.com/seeklay/ku/examples](https://gitlab.com/seeklay/ku/-/tree/main/examples)

## Documentation

* [v0.2-LATEST](https://ku-proxy.pp.seeklay.icu/v0.2)

## Quick intro

```python
from ku import ku
from time import sleep

listen = (
    "localhost", 25565, # domain names are IPv4 only
    "127.0.0.1", 80, # IPv4
    "[::1]", 8000 # IPv6
)

upstream = ("localhost", 8080) # host where all connection goes
proxy = ku(listen, upstream)

# proxy = ku(listen, ("google.com", 443), upstream_6=True) upstream_6 if you wanna use ipv6 with domain name in upstream

while 7:
    try:
        sleep(0.07)
    except KeyboardInterrupt:
        proxy.shutdown() # proxy creates a thread to async poll for socket events
        break            # we need to call shutdown() to break the thread loop
```

## Kun

proxy executable script / *alpha test*

```bash
$> kun --help

usage: -c [-h] [-v] -l localhost:65535 -u localhost:8000 [-7] [-ll] [-mc 15]
          [--transit]

Powerful fronted for ku-proxy

optional arguments:
  -h, --help          show this help message and exit
  -v                  If passed, enabling verbose logging
  -l localhost:65535  Proxy listen addr (allowed multiple and dualstack
                      hostnames) (enclose ipv6 like [::1])
  -u localhost:8000   Proxy upstream server addr
  -7                  Tells proxy to upstream over IPv6
  -ll                 If passed, enables low level debug logging (ku-proxy
                      debug)
  -mc 15              Maximum of parralel clients (connection over the limit
                      will be refused)
  --transit           If passed, enables transit (no session orientated)
                      displaying
```

## Projects that use ku-proxy

* MCRP 0.2.0+ <https://gitlab.com/cubelib/MCRP>
* Be the author of a new one!
