Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram. If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

signal_context.go 353B

12345678910111213141516171819202122232425
  1. // +build !windows
  2. package utils
  3. import (
  4. "context"
  5. "os"
  6. "os/signal"
  7. "syscall"
  8. )
  9. func GetSignalContext() context.Context {
  10. ctx, cancel := context.WithCancel(context.Background())
  11. sigChan := make(chan os.Signal, 1)
  12. signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
  13. go func() {
  14. for range sigChan {
  15. cancel()
  16. }
  17. }()
  18. return ctx
  19. }