Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/compscidr/kanonproxy
An anonymous proxy written in kotlin
https://github.com/compscidr/kanonproxy
anonymous-proxy hacktoberfest kotlin
Last synced: 2 days ago
JSON representation
An anonymous proxy written in kotlin
- Host: GitHub
- URL: https://github.com/compscidr/kanonproxy
- Owner: compscidr
- License: gpl-3.0
- Created: 2024-10-09T22:19:02.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-10-18T21:42:19.000Z (27 days ago)
- Last Synced: 2024-10-19T12:13:54.508Z (26 days ago)
- Topics: anonymous-proxy, hacktoberfest, kotlin
- Language: Kotlin
- Homepage:
- Size: 209 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# kanonproxy
[![JVM Tests](https://github.com/compscidr/kanonproxy/actions/workflows/test.yml/badge.svg)](https://github.com/compscidr/kanonproxy/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/compscidr/kanonproxy/graph/badge.svg?token=yBstrWw9Mm)](https://codecov.io/gh/compscidr/kanonproxy)An anonymous proxy written in kotlin.
This project is meant to be a library that can run on android or linux. It does not provide
the client / server functionality. It is able to process packets which have been parsed
by https://github.com/compscidr/knet, manage sessions and make outgoing anonymous requests
based on the incoming traffic. It also receives the return traffic, and puts them into a
queue.It is up to consumers of the this library to implement a server or a tun/tap adapter, or a
VPN service on Android to make use of this library.## Usage
The examples below show a contrived example where the packets are manually constructed. This
is a valid usecase, however, you probably want instead to parse a stream from an OS via a
TUN/TAP driver, or an Android VPN iostream or something. This library takes a list of
the `Packet` type from the knet library https://github.com/compscidr/knet, so if you have a
stream, you can convert that stream into a list of packets by parsing it with that lib.The other thing to note is that in order to handle Icmp traffic, we use the icmp library:
https://github.com/compscidr/icmp. Depending on whether you are on linux or android, you
should pass the appropriate `Icmp` object to the proxy. On linux its `IcmpLinux` on android
its `IcmpAndroid`. You also need to use different dependencies for each. For linux
`implementation("com.jasonernst.icmp:icmp-linux")` and for android
`implementation("com.jasonernst.icmp:icmp-android")`Linux:
```kotlin
val kanonProxy = KAnonProxy(IcmpLinux)val payload = "Test Data".toByteArray()
val sourceAddress = InetAddress.getByName("127.0.0.1") as Inet4Address
val sourcePort: UShort = 12345u
val destinationAddress = InetAddress.getByName("127.0.0.1") as Inet4Address
val destinationPort: UShort = 54321u
val udpHeader = UdpHeader(sourcePort, destinationPort, payload.size.toUShort())
val packet =
Packet(
Ipv4Header(
sourceAddress = sourceAddress,
destinationAddress = destinationAddress,
protocol = IpType.UDP.value,
totalLength =
(
Ipv4Header.IP4_MIN_HEADER_LENGTH +
udpHeader.totalLength +
payload.size.toUShort()
).toUShort(),
),
udpHeader,
payload,
)
val packets = listOf(packet)
kAnonProxy.handlePackets(packets)
val response = kanonProxy.takeResponse()
```There are more examples of usage in the [tests](src/test/kotlin/com/jasonernst/kanonproxy)