config.go 598 B

1234567891011121314151617181920212223242526272829303132333435
  1. package blackhole
  2. import (
  3. "github.com/v2ray/v2ray-core/common/alloc"
  4. v2io "github.com/v2ray/v2ray-core/common/io"
  5. )
  6. type Config struct {
  7. Response Response
  8. }
  9. type Response interface {
  10. WriteTo(v2io.Writer)
  11. }
  12. type NoneResponse struct{}
  13. func (this *NoneResponse) WriteTo(writer v2io.Writer) {}
  14. type HTTPResponse struct {
  15. }
  16. const (
  17. http403response = `HTTP/1.1 403 Forbidden
  18. Connection: close
  19. Cache-Control: max-age=3600, public
  20. Content-Length: 0
  21. `
  22. )
  23. func (this *HTTPResponse) WriteTo(writer v2io.Writer) {
  24. writer.Write(alloc.NewLocalBuffer(512).Clear().AppendString(http403response))
  25. }