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
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

root_context.go 368B

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