Example #1
0
package pubsub

import (
	"github.com/v2ray/v2ray-core/app"
)

const (
	APP_ID = app.ID(3)
)

type PubsubMessage []byte
type TopicHandler func(PubsubMessage)

type Pubsub interface {
	Publish(topic string, message PubsubMessage)
	Subscribe(topic string, handler TopicHandler)
}

type pubsubWithContext interface {
	Publish(context app.Context, topic string, message PubsubMessage)
	Subscribe(context app.Context, topic string, handler TopicHandler)
}

type contextedPubsub struct {
	context app.Context
	pubsub  pubsubWithContext
}

func (this *contextedPubsub) Publish(topic string, message PubsubMessage) {
	this.pubsub.Publish(this.context, topic, message)
}
Example #2
0
package proxyman

import (
	"github.com/v2ray/v2ray-core/app"
	"github.com/v2ray/v2ray-core/proxy"
)

const (
	APP_ID_INBOUND_MANAGER = app.ID(4)
)

type InboundHandlerManager interface {
	GetHandler(tag string) (proxy.InboundHandler, int)
}

type inboundHandlerManagerWithContext interface {
	GetHandler(context app.Context, tag string) (proxy.InboundHandler, int)
}

type inboundHandlerManagerWithContextImpl struct {
	context app.Context
	manager inboundHandlerManagerWithContext
}

func (this *inboundHandlerManagerWithContextImpl) GetHandler(tag string) (proxy.InboundHandler, int) {
	return this.manager.GetHandler(this.context, tag)
}

func init() {
	app.RegisterApp(APP_ID_INBOUND_MANAGER, func(context app.Context, obj interface{}) interface{} {
		manager := obj.(inboundHandlerManagerWithContext)
Example #3
0
package dispatcher

import (
	"github.com/v2ray/v2ray-core/app"
	v2net "github.com/v2ray/v2ray-core/common/net"
	"github.com/v2ray/v2ray-core/transport/ray"
)

const (
	APP_ID = app.ID(1)
)

// PacketDispatcher dispatch a packet and possibly further network payload to its destination.
type PacketDispatcher interface {
	DispatchToOutbound(packet v2net.Packet) ray.InboundRay
}

type packetDispatcherWithContext interface {
	DispatchToOutbound(context app.Context, packet v2net.Packet) ray.InboundRay
}

type contextedPacketDispatcher struct {
	context          app.Context
	packetDispatcher packetDispatcherWithContext
}

func (this *contextedPacketDispatcher) DispatchToOutbound(packet v2net.Packet) ray.InboundRay {
	return this.packetDispatcher.DispatchToOutbound(this.context, packet)
}

func init() {
Example #4
0
package dns

import (
	"net"

	"github.com/v2ray/v2ray-core/app"
)

const (
	APP_ID = app.ID(2)
)

// A DnsCache is an internal cache of DNS resolutions.
type Server interface {
	Get(domain string) []net.IP
}
Example #5
0
package api

import (
	"github.com/v2ray/v2ray-core/app"
)

const (
	APP_ID = app.ID(5)
)

type ApiServer struct {
}
Example #6
0
package proxyman

import (
	"sync"

	"github.com/v2ray/v2ray-core/app"
	"github.com/v2ray/v2ray-core/proxy"
)

const (
	APP_ID_INBOUND_MANAGER  = app.ID(4)
	APP_ID_OUTBOUND_MANAGER = app.ID(6)
)

type InboundHandlerManager interface {
	GetHandler(tag string) (proxy.InboundHandler, int)
}

type OutboundHandlerManager interface {
	GetHandler(tag string) proxy.OutboundHandler
	GetDefaultHandler() proxy.OutboundHandler
}

type DefaultOutboundHandlerManager struct {
	sync.RWMutex
	defaultHandler proxy.OutboundHandler
	taggedHandler  map[string]proxy.OutboundHandler
}

func NewDefaultOutboundHandlerManager() *DefaultOutboundHandlerManager {
	return &DefaultOutboundHandlerManager{