1
0

interfaces.go 907 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package cproxy
  2. import (
  3. "io"
  4. "net"
  5. "net/http"
  6. )
  7. type (
  8. Filter interface {
  9. IsAuthorized(http.ResponseWriter, *http.Request) bool
  10. }
  11. clientConnector interface {
  12. Connect(http.ResponseWriter) Socket
  13. }
  14. )
  15. type (
  16. Dialer interface {
  17. Dial(string) Socket
  18. }
  19. serverConnector interface {
  20. Connect(Socket, string) proxy
  21. }
  22. initializer interface {
  23. Initialize(Socket, Socket) bool
  24. }
  25. proxy interface {
  26. Proxy()
  27. }
  28. )
  29. type (
  30. Socket interface {
  31. io.ReadWriteCloser
  32. RemoteAddr() net.Addr
  33. }
  34. tcpSocket interface {
  35. Socket
  36. CloseRead() error
  37. CloseWrite() error
  38. }
  39. )
  40. type (
  41. monitor interface {
  42. Measure(int)
  43. }
  44. logger interface {
  45. Printf(string, ...interface{})
  46. }
  47. )
  48. const (
  49. MeasurementHTTPRequest int = iota
  50. MeasurementBadMethod
  51. MeasurementUnauthorizedRequest
  52. MeasurementClientConnectionFailed
  53. MeasurementServerConnectionFailed
  54. MeasurementProxyReady
  55. MeasurementProxyComplete
  56. )