madgiraffe1/flclash-egress-guard
حول
macOS menu bar kill switch for FlClash: locks the public internet when FlClash or its TUN drops, LAN keeps working. FlClash 掉线时锁住公网的 Mac 断网保护。
الأمان والخصوصيةالنمو المقاس للنجوم
- خلال 24 ساعة
- ٠
- خلال 7 أيام
- ٠
- خلال 15 يومًا
- جارٍ جمع السجل
- خلال شهر
- جارٍ جمع السجل
تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.
README.md
الأصل
FlClash Egress Guard
A menu-bar kill switch for FlClash on macOS.
When FlClash or its TUN drops, your Mac's internet locks instead of quietly going direct. Your LAN keeps working.
English · 简体中文

[!NOTE] The app supports English and Simplified Chinese. It follows your system language by default: Chinese uses Chinese; all other languages use English. Use Language in the panel or menu-bar popover to choose Follow System, 中文 or English. Changes apply immediately and are remembered.
Contents
- What it does
- Quick start: download, install, guided setup
- Everyday use
- Typical scenarios
- System requirements · Settings · Uninstall
- FAQ · Verify protection · Troubleshooting · Security and privacy
- Roadmap · Feedback · Acknowledgements · License
What it does
With FlClash's TUN mode on, your Mac's traffic goes through FlClash. But if FlClash quits, crashes, restarts for an update or loses its TUN, macOS silently switches back to a direct connection. Your apps keep working, just not through FlClash, and nothing tells you.
FlClash Egress Guard stops that from happening:
- Locks the internet when FlClash stops. The OS notifies the guard when FlClash's core exits, so locking is usually almost immediate. TUN and route changes are checked roughly once a second.
- Nothing gets around FlClash. While connected, apps can only go online through FlClash. That includes background services and command-line tools that ignore proxy settings.
- Your local network keeps working. Printers, NAS, AirPlay, your router and
localhoststay reachable even while the internet is locked. - Guided reconnection. Click Reconnect FlClash, then follow the wizard to check protection and test the connection.
- Optional boot protection. Every session starts locked, until you connect FlClash.
- Simple and private. Your password is needed only once. FlClash's subscriptions, rules and DNS are left untouched. There's no telemetry, and one button undoes everything.
It works with the firewall built into macOS, so there's nothing else to install.
The screenshots and animation render the app’s actual views with sample states; they do not record a live network change.
Quick start
Allow about five minutes. Follow the app's prompts to authorize it, connect FlClash and check protection.
Before you start
- An Apple silicon Mac (M1 or newer) with macOS 13 Ventura or later. Check under Apple menu › About This Mac.
- FlClash in the main Applications folder (
/Applications/FlClash.app), with TUN turned on and working. In FlClash's Chinese interface this switch is called 虚拟网卡. - Your Mac's administrator password.
- Command Line Tools for Xcode. If they're missing, macOS offers to install them the first time the app needs them; click Install.
- No other VPN or firewall app running, and Internet Sharing turned off.
Step 1: Download
Download FlClash-Egress-Guard-macOS-arm64.zip from the latest release, then double-click it in your Downloads folder to unzip it. The app is displayed as FlClash Egress Guard in English. Its bundle filename remains FlClash 出网保护.app; keep that filename for boot protection.
Step 2: Move it into your personal Applications folder
Put the app in the Applications folder inside your home folder (~/Applications), not the main one, and keep its name unchanged. Boot protection looks for it there.
- In Finder choose Go › Home (⇧⌘H).
- Open the Applications folder there. If there isn't one, create a folder named exactly
Applications. - Drag FlClash Egress Guard into it.
Step 3: Open it the first time
The app is signed locally but not notarized by Apple, so macOS asks you to confirm the first launch:
- Double-click the app. macOS says it can't verify it; click Done.
- Open System Settings › Privacy & Security, scroll down to Security, and click Open Anyway next to FlClash Egress Guard.
- Enter your Mac password, then click Open.
On macOS 13 or 14 you can instead Control-click the app and choose Open, then Open again. You only do this once.
Step 4: Authorize once (①)
The Egress protection window opens. At the bottom right, click Authorize once and enter your Mac password in the macOS dialog. The footer changes to System helper authorized. From now on, turning protection on and off won't ask for your password.

Step 5: Turn on daily protection (②)
Click Turn on daily protection. If you skipped step 4, the app asks for authorization first and then carries on.
The panel shows four steps as it checks everything. If it says Action needed, do what it asks, then click Continue:
| The panel asks… | What to do |
|---|---|
| Click the FlClash menu-bar icon and choose Quit… | Click FlClash's menu-bar icon and choose 退出 (Exit). When the icon disappears, click Continue. The app reopens FlClash in protected mode. |
| Open FlClash and make sure TUN is on… | Open FlClash, turn on 虚拟网卡 (TUN), then click Continue. |

Step 6: Done
When the panel shows On with a green dot, you're protected. The app has checked the firewall and loaded Google and Douyin through FlClash. Close the window whenever you like: protection keeps running and the shield stays in the menu bar.

[!TIP] Want the Mac to start locked, too? Turn on boot protection. It's one more click.
Everyday use
The menu-bar shield
Click the shield for a quick status. Open panel opens the full window, and the power button quits the menu-bar app. Quitting the app doesn't turn protection off.
The footer's GitHub repository link opens the source in your default browser. About shows the app name, version, MIT license, repository and author profile; it is also available in the app menu.

| Icon | Panel shows | Meaning |
|---|---|---|
| On | Protected. Apps go online only through FlClash. | |
| Internet locked | FlClash quit or lost its TUN. The LAN still works. Click Reconnect FlClash to start the wizard. | |
| Off | Protection is off. Apps use the network normally. | |
| Not checked / Re-check | Something changed, for example FlClash just started or quit. Click the shield to check. |
When it says Internet locked
That's the kill switch doing its job. Click the shield, then Open panel, then Reconnect FlClash to start the four-step wizard:
- Check status: the app reads the current protection rules.
- Connect FlClash: the app starts FlClash with the dedicated identity if needed. If prompted to quit FlClash first, quit it from its menu-bar icon, then click Continue. If prompted about TUN, turn on 虚拟网卡 (TUN) in FlClash, then click Continue.
- Apply rules: the app loads the protection rules and reads them back to verify them.
- Test connection: the app checks Google and Douyin. When the checks finish successfully, the panel shows On in green.

Boot protection (optional)
Without it, protection lasts until you restart. With it, your Mac starts with the internet locked, and the shield appears in the menu bar after you log in; open it, click Reconnect FlClash and follow the wizard.
Click Turn on boot protection. To stop it later, click Turn off boot protection…; this only affects future restarts. If it ever shows Login launch incomplete, click Complete login launch.

[!TIP] If FlClash is set to 自启动 (Auto launch), you'll be asked to quit it once at every login. With boot protection on, you may prefer to switch FlClash's auto launch off and let this app open FlClash for you.
After a restart
- Boot protection on: click the shield, then Open panel and Reconnect FlClash, and follow the wizard.
- Boot protection off: open FlClash Egress Guard from
~/Applications, click Turn on daily protection again and follow the wizard.
Back to normal internet
Remove all protection… turns protection off and restores your original setup. If FlClash is still running, quit it and click the button once more to finish cleaning up.

Updating the app
Quit the menu-bar app (protection keeps running), replace ~/Applications/FlClash 出网保护.app with the new version and open it. Click Authorize once again when it asks; each version needs its own authorization.
View log shows a simple history of checks: time, check name, pass or fail.
Typical scenarios
- Everyday proxy use without silent leaks. FlClash crashes, an update restarts it, or you quit it by mistake: your Mac goes offline instead of going direct.
- Every session starts locked. With boot protection, apps that start at login (cloud sync, chat, browsers restoring tabs) can't get online before FlClash is connected.
- Keep command-line tools and background services on the proxy. Scripts, package managers, AI coding agents and system services can only get out through FlClash.
- Home or office LAN while locked. Printing, NAS, AirPlay, SSH to a Raspberry Pi and local dev servers keep working.
- Wi-Fi with a login page (hotels, airports). While the internet is locked, the login page can't load. Click Remove all protection…, log in, then turn protection back on.
System requirements
| Mac | Apple silicon (M1 or newer). |
| macOS | 13 Ventura or later. |
| FlClash | Installed at /Applications/FlClash.app, with TUN (虚拟网卡) working. |
| Other | An administrator account. Command Line Tools for Xcode. No other VPN or firewall app active; Internet Sharing off. |
Settings
Use Language in the panel or menu-bar popover to choose Follow System, 中文 or English. The selection is saved automatically; switching languages does not change protection. Follow System uses Chinese for a Chinese system language and English otherwise.
The other settings are buttons in the app.
| Button | What it does |
|---|---|
| Authorize once / Revoke authorization… | Lets the app manage protection without asking for your password, or takes that permission back. Protection itself is unaffected. |
| Turn on daily protection / Reconnect FlClash | Starts the wizard to connect FlClash, verify protection rules and test the connection. Protection lasts until you restart or remove it. |
| Turn on boot protection / Turn off boot protection… | Starts every session with the internet locked. |
| Remove all protection… | Restores your original setup. |
| Refresh status · View log | Re-checks the status · opens the log. |
In FlClash, just keep 虚拟网卡 (TUN) on. Its rules, subscriptions, proxy groups and DNS are yours to change as usual.
Uninstall
- In the app, click Remove all protection… and confirm. If FlClash was running, quit it and click the button once more.
- Click Revoke authorization….
- Quit the menu-bar app (shield › power button) and move FlClash Egress Guard to the Trash.
- Optional: delete
~/Library/Logs/FlClashEgressGuardand~/Library/Preferences/local.flclash.egressguard.control.plist.
From now on, open FlClash the usual way.
If the app won't open, use Terminal
sudo "$HOME/Applications/FlClash 出网保护.app/Contents/Resources/egress-guard" rollback
sudo "$HOME/Applications/FlClash 出网保护.app/Contents/Resources/guard-authorize" remove "$(id -u)"
The first command removes the protection, the second removes the authorization. If the first says FlClash is still in use, quit FlClash and run it again.
FAQ
Does it change my FlClash settings?
No. Subscriptions, rules, overrides, proxy groups and DNS stay exactly as they are.
Does it work with other clients or VPNs (Clash Verge, ClashX, Surge…)?
No. It's made for FlClash. Other VPNs generally won't work while protection is on.
Do I need to keep the app open?
No. Protection keeps running after you close the window or quit the app.
I quit FlClash on purpose. Why is my internet gone?
That's the kill switch. Click Reconnect FlClash and follow the reconnection wizard, or Remove all protection… to use the internet without it.
Will my printer, NAS, AirPlay or local servers keep working?
Yes, as long as they're on your local network. Addresses in 100.64.0.0/10 (used by Tailscale, for example) don't count as local.
Does protection survive a restart?
Daily protection doesn't, so click Turn on daily protection again after restarting and follow the wizard. Turn on boot protection if you want every session to start locked.
Why Google and Douyin?
They're the final check that the connection really works. If one can't load on your network, step 4 shows Not finished, but protection is still on.
Does it work on Intel Macs?
No. The release is for Apple silicon only.
macOS said "Background Items Added". Is that normal?
Yes. The authorization and boot protection each add a background item. Please manage them with the app's buttons, not in System Settings.
How to verify protection works
Don't test while something important is running. The steps below quit FlClash on purpose, which locks the internet and cuts any session going through it.
First click Turn on daily protection, finish the four steps, and wait for the panel to show a green On. You can also click Refresh status. While protection is loaded, the command below should print 保护已装载,核心使用 ("Protection is loaded; the core uses") followed by a utun name. The command-line tool prints its messages in Chinese. Reading the kernel pf state needs administrator rights.
sudo "$HOME/Applications/FlClash 出网保护.app/Contents/Resources/egress-guard" status
If FlClash and its TUN are still up, you can also run preview for a read-only check, without sudo. On success it tells you which utun the core holds. Once the internet is locked the core has exited, so this no longer applies; use status instead.
"$HOME/Applications/FlClash 出网保护.app/Contents/Resources/egress-guard" preview
Now quit FlClash from its menu-bar icon. The shield or panel should switch to Internet locked. Run status again and it should print 公网出口已锁定;局域网和回环例外仍有效。 ("The internet is locked. LAN and loopback access remain available."). You can also list the active rules in the anchor. While locked you should see fcg-deny, or fcg-boot-deny for boot protection, and no longer fcg-core or fcg-tun.
sudo pfctl -a com.apple/000.flclash-egress-guard -sr
Next, check the internet is locked using the same targets the tool checks. It tests Google and Douyin with curl, --max-time 6 and --noproxy "*". The final rule is block drop out, so packets are dropped and curl usually waits until it times out, most often with exit code 28 and sometimes 7. If your system DNS points at a public resolver, name resolution itself may fail with exit code 6. The tool's lock check treats both as "can't connect".
Test Google and Douyin once each:
curl -q --noproxy "*" --max-time 6 -o /dev/null -w "%{http_code}\n" https://www.google.com/
curl -q --noproxy "*" --max-time 6 -o /dev/null -w "%{http_code}\n" https://www.douyin.com/
To leave DNS out of it, test port 443 on 1.1.1.1, which the lock check also uses. It should time out as well.
curl -q --noproxy "*" --max-time 6 -o /dev/null https://1.1.1.1/
The LAN and loopback should still work. For example, the command below should succeed, and your router or other LAN addresses should be reachable. If you curl a local port where nothing is listening, the connection fails right away instead of timing out.
ping -c 2 127.0.0.1
When you're done, click Reconnect FlClash and follow the wizard. The panel should return to a green On, and status should again print 保护已装载,核心使用. The curl commands for Google and Douyin should get an HTTP status code back. In the app you can also click View log, or open ~/Library/Logs/FlClashEgressGuard/保护日志.txt, which records each check and whether it passed.
Troubleshooting
The panel shows what went wrong. The most common messages:
| Message | What to do |
|---|---|
| Open FlClash and make sure its core is running. | Open FlClash, then click Retry. |
| FlClash is running. Quit it manually before changing its launch identity. | Quit FlClash from its menu-bar icon, then click Continue. |
| A single TUN belonging to the core could not be identified. / The core’s TUN is not enabled. | Turn on 虚拟网卡 (TUN) in FlClash, wait a moment, then retry. |
| The core has an unexpected parent process or identity. | Make sure TUN works in FlClash on its own, then retry. |
| …did not return a web page. Check the selected FlClash node, then click Retry. | Protection is on, but a test site didn't load. Check your FlClash node, then retry. |
| Other active filter rules were found. Check their order; they have been left in place. / Other active address translation rules were found. Check the connection states they create. | Another VPN or firewall, or Internet Sharing, is active. Turn it off and retry. |
| Could not connect to the system helper. Click “Authorize once” to register it again. | Click Authorize once again (common after updating the app). |
macOS won't open the app. Follow step 3.
macOS asks to install "command line developer tools". Click Install, wait until it finishes, and open the app again.
I need the internet back right now. Click Remove all protection…. If the app won't open, use the Terminal commands under Uninstall.
Still stuck? Open an issue with your macOS version, the panel's message and the relevant log lines. Remove anything personal first: node addresses, subscription links, IP addresses, user names.
Security and privacy
- Your password is only ever typed into macOS's own dialog; the app never sees it.
- The app never changes or removes other apps' firewall settings. If something is in the way, it stops and tells you.
- No telemetry. The only connections the app makes itself are its checks to Google, Douyin and
1.1.1.1. - The log holds only times, check names and pass/fail. No addresses.
- It's a safety net, not antivirus: software that already has administrator rights could still change the firewall.
- Download only from the official release page. From the folder containing the downloaded ZIP, compare the SHA-256 shown there with
shasum -a 256 FlClash-Egress-Guard-macOS-arm64.zip.
Found a security problem? Please report it privately; see SECURITY.md.
Roadmap
Ideas, not promises:
- Notarized releases, so the first launch needs no extra steps.
- Intel Mac support.
- Choosing your own test sites.
- FlClash installed outside
/Applications.
Feedback
The source code is public in this repository. Feedback and pull requests are welcome: report a bug or suggest a feature (see CONTRIBUTING.md). Please follow the Code of Conduct.
Acknowledgements
- FlClash by chen08209, the client this app works with.
- mihomo (Clash.Meta), FlClash's core.
- Shields.io for the badges.
FlClash Egress Guard is an independent project, not affiliated with or endorsed by FlClash.
License
MIT © 2026 madgiraffe1. FlClash, mihomo and macOS are separate products covered by their own licenses.
Friendly Links
- LINUX DO, a new ideal community.
استكشف مشاريع مشابهة ومرتبطة
جارٍ التحميل…