{"id":15679161,"url":"https://github.com/robertying/tunet-c","last_synced_at":"2025-06-15T09:34:48.941Z","repository":{"id":134457474,"uuid":"163529734","full_name":"robertying/tunet-c","owner":"robertying","description":"C cli and library for Tsinghua University network authentication","archived":false,"fork":false,"pushed_at":"2020-09-01T12:52:25.000Z","size":225,"stargazers_count":14,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T09:17:15.678Z","etag":null,"topics":["android","c","linux","mac","openwrt","tsinghua-university","tunet"],"latest_commit_sha":null,"homepage":"","language":"C","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/robertying.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-29T17:43:03.000Z","updated_at":"2024-04-12T17:56:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"4def197f-704e-496f-b248-bea7810f6ce0","html_url":"https://github.com/robertying/tunet-c","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/robertying/tunet-c","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertying%2Ftunet-c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertying%2Ftunet-c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertying%2Ftunet-c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertying%2Ftunet-c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertying","download_url":"https://codeload.github.com/robertying/tunet-c/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertying%2Ftunet-c/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259952457,"owners_count":22936956,"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":["android","c","linux","mac","openwrt","tsinghua-university","tunet"],"created_at":"2024-10-03T16:26:33.833Z","updated_at":"2025-06-15T09:34:48.918Z","avatar_url":"https://github.com/robertying.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tunet-c\n\nC cli and library for Tsinghua University network authentication.\n\nSupport `auth4`, `auth6` and `net`, including `wired` and wireless `Tsinghua-5G`, `Tsinghua` and `Tsinghua-IPv4`.\n\nYou can use it as a command line tool or integrate the lib into any application.\n\nInstallation on `OpenWrt` is also available!\n\n## Usage\n\n```sh\n# Create a config file\nvi ~/.tunet_config\n# Fill in your username and password on each line\n\n# Set proper permissions\nchmod 600 ~/.tunet_config\n\n# Use it!\ntunet -m auth4 -c ~/.tunet_config -r\n\n# or\ntunet -m auth4 -u yingr16 -p iampassword -r\n```\n\n### Notes\n\nEntering your password in command line is extremely inappropriate.\n\nPlease use a config file and make sure you are the only one who can access it.\n\n### Arguments\n\n```\n        -u       Tsinghua username\n        -p       Tsinghua password (wrap it in single quotes if it contains special characters)\n                    Caution: enter password in cli is not recommended\n                    Please use config file instead\n        -r       Logout first before logging in; useful when network left inactive for too long\n        -m       Network choice: [net auth auth4 auth6]\n        -c       Credential config file path\n                    Username should be in the first line and password in the second\n        -h       Usage help\n```\n\n## Installation\n\n### OpenWrt\n\n#### Prebuilt Binary\n\n\u003cdel\u003eFor OpenWrt users, you can download prebuilt binary from [releases](https://github.com/robertying/tunet-c/releases).\u003c/del\u003e\n\n_**There is no prebuilt binary for newer versions. The following guide only serves as a reference for installation. You need to [compile the binary](#Build-From-Source) by yourself.**_\n\nUpload them to your router and use `opkg` to install packages.\n\nFor example, if you are using a `mipsel_24kc` router and packages are uploaded to `/tmp`, run:\n\n```sh\nopkg install /tmp/libtidy_5.7.28-1_mipsel_24kc.ipk\nopkg install /tmp/libtunet_4.0.0-1_mipsel_24kc.ipk\nopkg install /tmp/tunet_4.0.0-1_mipsel_24kc.ipk\n```\n\nYou could add an init script to run `tunet` on boot.\n\n```sh\nvi /etc/init.d/tunet\n```\n\nWith the following content:\n\n```sh\n#!/bin/sh /etc/rc.common\n# /etc/init.d/tunet\n\nSTART=99\nDELAY=10\n\nstart() {\n        tunet -m auth4 -c /root/.tunet_config -r\n}\n\nboot() {\n        [ $DELAY -gt 0 ] \u0026\u0026 sleep $DELAY\n        start\n}\n```\n\n```sh\nchmod +x /etc/init.d/tunet\n/etc/init.d/tunet enable\n```\n\nYou can also add a cron job to run `/etc/init.d/tunet start` periodically in case the network somehow become logged out after inactivity.\n\n#### Build From Source\n\nCurrently, `tunet` is tested on `ramips/mt7620` and should work consistently for all targets.\n\nOther platforms will be added gradually and you can always file an issue to request pre-compiled binary for these platforms.\n\n\u003cdetails\u003e\n\u003csummary\u003e\n\u003cstrong\u003eHere are details for those who want to build the binary by themselves\u003c/strong\u003e\n\u003c/summary\u003e\n\n1. Get ready by following [Install buildsystem](https://openwrt.org/docs/guide-developer/build-system/install-buildsystem) and install prerequisites.\n\n2. Download OpenWrt SDK for your platform. Follow [Using the SDK](https://openwrt.org/docs/guide-developer/using_the_sdk).\n\n3. For example, for mt7620 and OpenWrt 19.07.0, download and unzip `openwrt-sdk-19.07.0-ramips-mt7620_gcc-7.5.0_musl.Linux-x86_64.tar.xz`:\n\n   ```sh\n   tar xvf openwrt-sdk-19.07.0-ramips-mt7620_gcc-7.5.0_musl.Linux-x86_64.tar.xz\n   ```\n\n4. Add `tunet` into SDK feeds `feeds.conf.default`:\n\n   ```sh\n   cd openwrt-sdk-19.07.0-ramips-mt7620_gcc-7.5.0_musl.Linux-x86_64\n   ```\n\n   Edit the file `feeds.conf.default`. Add the following line:\n\n   ```\n   src-git tunet https://github.com/robertying/tunet-c.git\n   ```\n\n5. Use `./scripts/feeds update -a` command to obtain and update package definitions.\n\n6. After the definitions have been updated, run `./scripts/feeds install libtidy tunet` to prepare the package and its dependencies.\n\n7. Run `make menuconfig` and go to `Global Build Settings` to exclude the following:\n\n   ```\n   [ ] Select all target specific packages by default\n   [ ] Select all kernel module packages by default\n   [ ] Select all userspace packages by default\n   ```\n\n8. Exit and go to `Network`, select `tunet` by pressing `m` and all the dependencies will be selected automatically.\n\n9. Save the configuration and exit the menu.\n\n10. Run `make package/tunet/compile -j5`\n\n11. After the compilation is finished, the generated .ipk files are placed in the `bin/packages/$ARCH/tunet/` of the directory you extracted the SDK into.\n\n\u003c/details\u003e\n\n### Linux \u0026 macOS\n\nNow you can only build `tunet` from source for general Linux distributions or macOS.\n\nYou need prerequisites like `openssl`, `curl` and `tidy-html5` so that `libcrypto`, `libcurl` and `libtidy` exist in system PATH.\n\nFor example, macOS users should do:\n\n```bash\nbrew install openssl curl tidy-html5\nexport LDFLAGS=\"-L/usr/local/opt/openssl/lib -L/usr/local/opt/curl/lib -L/usr/local/opt/tidy-html5/lib\"\nexport CPPFLAGS=\"-I/usr/local/opt/openssl/include -I/usr/local/opt/curl/include -I/usr/local/opt/tidy-html5/include\"\n```\n\nAnd Linux (Ubuntu) users should do:\n\n```bash\nsudo apt update\nsudo apt install libssl-dev libcurl4-openssl-dev libtidy-dev\n```\n\nThen build and install:\n\n```bash\ngit clone --recursive https://github.com/robertying/tunet-c.git\ncd tunet-c\n./autogen.sh\n./configure --prefix=/usr/local/\nmake\nsudo make install\n```\n\nBy default, the binary `tunet` is installed in `$prefix/bin`. Change `--prefix=/usr/local/` to other directories if you want.\n\nA shared library `libtunet` in `$prefix/lib` and a header file `tunet.h` in `$prefix/include` are provided as well if you want to integrate it yourself.\n\n### Android\n\nSee [CampusNet-Android](https://github.com/robertying/CampusNet-Android) for details about NDK integration.\n\n## Contributing\n\nPlease file an issue if you encounter any problem or want new features.\n\nPull requests are mostly welcomed but will be considered carefully.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertying%2Ftunet-c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertying%2Ftunet-c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertying%2Ftunet-c/lists"}