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

events.go 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. package mtglib
  2. import (
  3. "net"
  4. "time"
  5. )
  6. type eventBase struct {
  7. streamID string
  8. timestamp time.Time
  9. }
  10. func (e eventBase) StreamID() string {
  11. return e.streamID
  12. }
  13. func (e eventBase) Timestamp() time.Time {
  14. return e.timestamp
  15. }
  16. type EventStart struct {
  17. eventBase
  18. RemoteIP net.IP
  19. }
  20. type EventConnectedToDC struct {
  21. eventBase
  22. RemoteIP net.IP
  23. DC int
  24. }
  25. type EventTraffic struct {
  26. eventBase
  27. Traffic uint
  28. IsRead bool
  29. }
  30. type EventFinish struct {
  31. eventBase
  32. }
  33. type EventDomainFronting struct {
  34. eventBase
  35. }
  36. type EventConcurrencyLimited struct {
  37. eventBase
  38. }
  39. type EventIPBlocklisted struct {
  40. eventBase
  41. RemoteIP net.IP
  42. }
  43. type EventReplayAttack struct {
  44. eventBase
  45. }
  46. func NewEventStart(streamID string, remoteIP net.IP) EventStart {
  47. return EventStart{
  48. eventBase: eventBase{
  49. timestamp: time.Now(),
  50. streamID: streamID,
  51. },
  52. RemoteIP: remoteIP,
  53. }
  54. }
  55. func NewEventConnectedToDC(streamID string, remoteIP net.IP, dc int) EventConnectedToDC {
  56. return EventConnectedToDC{
  57. eventBase: eventBase{
  58. timestamp: time.Now(),
  59. streamID: streamID,
  60. },
  61. RemoteIP: remoteIP,
  62. DC: dc,
  63. }
  64. }
  65. func NewEventTraffic(streamID string, traffic uint, isRead bool) EventTraffic {
  66. return EventTraffic{
  67. eventBase: eventBase{
  68. timestamp: time.Now(),
  69. streamID: streamID,
  70. },
  71. Traffic: traffic,
  72. IsRead: isRead,
  73. }
  74. }
  75. func NewEventFinish(streamID string) EventFinish {
  76. return EventFinish{
  77. eventBase: eventBase{
  78. timestamp: time.Now(),
  79. streamID: streamID,
  80. },
  81. }
  82. }
  83. func NewEventDomainFronting(streamID string) EventDomainFronting {
  84. return EventDomainFronting{
  85. eventBase: eventBase{
  86. timestamp: time.Now(),
  87. streamID: streamID,
  88. },
  89. }
  90. }
  91. func NewEventConcurrencyLimited() EventConcurrencyLimited {
  92. return EventConcurrencyLimited{
  93. eventBase: eventBase{
  94. timestamp: time.Now(),
  95. },
  96. }
  97. }
  98. func NewEventIPBlocklisted(remoteIP net.IP) EventIPBlocklisted {
  99. return EventIPBlocklisted{
  100. eventBase: eventBase{
  101. timestamp: time.Now(),
  102. },
  103. RemoteIP: remoteIP,
  104. }
  105. }
  106. func NewEventReplayAttack(streamID string) EventReplayAttack {
  107. return EventReplayAttack{
  108. eventBase: eventBase{
  109. timestamp: time.Now(),
  110. streamID: streamID,
  111. },
  112. }
  113. }