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文字以内のものにしてください。

root_context.go 348B

12345678910111213141516171819202122232425
  1. // +build !windows
  2. package utils
  3. import (
  4. "context"
  5. "os"
  6. "os/signal"
  7. "syscall"
  8. )
  9. func RootContext() 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. }