当前位置: 首页>>代码示例>>Golang>>正文


Golang ReqTunnel.Hostname方法代码示例

本文整理汇总了Golang中ngrok/msg.ReqTunnel.Hostname方法的典型用法代码示例。如果您正苦于以下问题:Golang ReqTunnel.Hostname方法的具体用法?Golang ReqTunnel.Hostname怎么用?Golang ReqTunnel.Hostname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ngrok/msg.ReqTunnel的用法示例。


在下文中一共展示了ReqTunnel.Hostname方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: registerTunnel

// Register a new tunnel on this control connection
func (c *Control) registerTunnel(rawTunnelReq *msg.ReqTunnel) {
	for _, proto := range strings.Split(rawTunnelReq.Protocol, "+") {
		tunnelReq := *rawTunnelReq
		tunnelReq.Protocol = proto

		c.conn.Debug("Registering new tunnel")
		t, err := NewTunnel(&tunnelReq, c)
		if err != nil {
			c.out <- &msg.NewTunnel{Error: err.Error()}
			if len(c.tunnels) == 0 {
				c.shutdown.Begin()
			}

			// we're done
			return
		}

		// add it to the list of tunnels
		c.tunnels = append(c.tunnels, t)

		// acknowledge success
		c.out <- &msg.NewTunnel{
			Url:      t.url,
			Protocol: proto,
			ReqId:    rawTunnelReq.ReqId,
		}

		rawTunnelReq.Hostname = strings.Replace(t.url, proto+"://", "", 1)
	}
}
开发者ID:monkeyregal,项目名称:ngrok,代码行数:31,代码来源:control.go

示例2: registerTunnel

// Register a new tunnel on this control connection
func (c *Control) registerTunnel(rawTunnelReq *msg.ReqTunnel) {
	for _, proto := range strings.Split(rawTunnelReq.Protocol, "+") {
		tunnelReq := *rawTunnelReq
		tunnelReq.Protocol = proto

		c.conn.Debug("Registering new tunnel")
		t, err := NewTunnel(&tunnelReq, c)
		if err != nil {
			ack := &msg.NewTunnel{Error: err.Error()}
			if len(c.tunnels) == 0 {
				// you can't fail your first tunnel registration
				// terminate the control connection
				c.stop <- ack
			} else {
				// inform client of failure
				c.out <- ack
			}

			// we're done
			return
		}

		// add it to the list of tunnels
		c.tunnels = append(c.tunnels, t)

		// acknowledge success
		c.out <- &msg.NewTunnel{
			Url:      t.url,
			Protocol: proto,
			ReqId:    rawTunnelReq.ReqId,
		}

		rawTunnelReq.Hostname = strings.Replace(t.url, proto+"://", "", 1)
	}
}
开发者ID:jedibatman,项目名称:ngrok,代码行数:36,代码来源:control.go


注:本文中的ngrok/msg.ReqTunnel.Hostname方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。