{"id":20677454,"url":"https://github.com/operatorfoundation/flower","last_synced_at":"2025-04-19T20:57:57.403Z","repository":{"id":49803290,"uuid":"155779342","full_name":"OperatorFoundation/Flower","owner":"OperatorFoundation","description":"A simple protocol for packet encapsulation","archived":false,"fork":false,"pushed_at":"2023-07-19T20:32:58.000Z","size":87,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-29T13:22:46.889Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OperatorFoundation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-01T21:41:44.000Z","updated_at":"2023-06-29T08:03:12.000Z","dependencies_parsed_at":"2022-08-22T12:00:12.422Z","dependency_job_id":null,"html_url":"https://github.com/OperatorFoundation/Flower","commit_stats":null,"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OperatorFoundation%2FFlower","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OperatorFoundation%2FFlower/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OperatorFoundation%2FFlower/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OperatorFoundation%2FFlower/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OperatorFoundation","download_url":"https://codeload.github.com/OperatorFoundation/Flower/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249800241,"owners_count":21327024,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T21:15:39.395Z","updated_at":"2025-04-19T20:57:57.343Z","avatar_url":"https://github.com/OperatorFoundation.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Operator Foundation\n\n[Operator](https://operatorfoundation.org) makes useable tools to help people around the world with censorship, security, and privacy.\n\n## Flower\n\nFlower is a simple protocol for packet encapsulation. The Flower library can be integrated into Swift applications running on iOS or macOS. The intended use case is for macOS and iOS Network Extensions. A Network Extension is the Apple-approved way to create custom VPN protocols.\n\n### Usage\n\n#### Obtain a Connection\n\nThe Flower library does not provide connections. A Connection must be obtained elsewhere, either a NWConnection from the Network framework or any transport Connection type from the Shapeshifter library.\n\n##### Example using an NWConnection\n\n    import Network\n    \n    let conn = NWConnection(host: NWEndpoint.Host(\"localhost\"), port: NWEndpoint.Port(integerLiteral: 5555), using: .tcp)\n    conn.start(queue: .global())\n\n##### Example using Shapeshifter transport Connection\n\n    import Shapeshifter-Swift-Transports\n    \n    // Only use Rot13 transport for examples, never for real deployments.\n    let factory = Rot13ConnectionFactory((host: NWEndpoint.Host(\"localhost\"), port: NWEndpoint.Port(integerLiteral: 5555))\n    let conn = factory.connect(using: .tcp)\n\n#### Create Message objects\n\nCreate Message objects for encapsulated packets.\n\n##### Example using IPv4 packet\n\n    import Flower\n\n    let data = Data(repeating: 0x00, count: 80)\n    let message = Message.IPDataV4(data)\n\n##### Example using IPv6 packet\n\n    import Flower\n\n    let data = Data(repeating: 0x00, count: 80)\n    let message = Message.IPDataV6(data)\n\n#### Send Message objects over Connection\n\nFlower extends the Connection protocol to include the ```sendMessage``` function. You can call ```sendMessage``` on any\nConnection.\n\n    conn.sendMessage(message)\n    {\n      maybeError in\n      \n      // Handle errors while attempting to send message\n    }\n    \n#### Read Message objects from Connection\n\nFlower extends the Connection protocol to include the ```readMessages``` function. You can call ```readMessages``` on any\nConnection.\n\n    conn.readMessages\n    {\n      message in\n      \n      switch message\n      {\n        case .IPDataV4(let data):\n          print(\"Received an IPv4 packet\")\n        case .IPDataV6(let data):\n          print(\"Receieved an IPv6 packet\")\n      }\n    }\n    \nThe ```readMessages``` function only needs to be called once. It will call the provided callback multiple times, once\nfor each packet received.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foperatorfoundation%2Fflower","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foperatorfoundation%2Fflower","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foperatorfoundation%2Fflower/lists"}