mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
opt some
This commit is contained in:
parent
0f65bdb891
commit
050e796486
@ -13,13 +13,13 @@ import (
|
||||
)
|
||||
|
||||
func _broad_addr(m *ice.Message, host, port string) *net.UDPAddr {
|
||||
if addr, e := net.ResolveUDPAddr("udp4", kit.Format("%s:%s", host, port)); !m.Warn(e != nil, e, host, port, logs.FileLineMeta(logs.FileLine(2))) {
|
||||
if addr, e := net.ResolveUDPAddr("udp4", kit.Format("%s:%s", host, port)); !m.Warn(e, ice.ErrNotValid, host, port, logs.FileLineMeta(2)) {
|
||||
return addr
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func _broad_send(m *ice.Message, host, port string, remote_host, remote_port string) {
|
||||
if s, e := net.DialUDP("udp", nil, _broad_addr(m, remote_host, remote_port)); m.Assert(e) {
|
||||
if s, e := net.DialUDP("udp", nil, _broad_addr(m, remote_host, remote_port)); !m.Warn(e, ice.ErrNotValid) {
|
||||
defer s.Close()
|
||||
msg := m.Spawn(kit.Dict(tcp.HOST, host, tcp.PORT, port))
|
||||
m.Logs(mdb.EXPORT, BROAD, msg.FormatMeta(), "to", remote_host+ice.DF+remote_port)
|
||||
@ -42,7 +42,7 @@ func _broad_serve(m *ice.Message, host, port string) {
|
||||
if m.Cmd(BROAD, kit.Format("%s,%s", msg.Option(tcp.HOST), msg.Option(tcp.PORT))).Length() > 0 {
|
||||
continue
|
||||
}
|
||||
if remote := _broad_addr(m, msg.Option(tcp.HOST), msg.Option(tcp.PORT)); !m.Warn(remote == nil) {
|
||||
if remote := _broad_addr(m, msg.Option(tcp.HOST), msg.Option(tcp.PORT)); remote != nil {
|
||||
m.Cmd(BROAD, func(value ice.Maps) {
|
||||
m.Logs(mdb.EXPORT, BROAD, kit.Format(value), "to", kit.Format(remote))
|
||||
s.WriteToUDP([]byte(m.Spawn(value).FormatMeta()), remote)
|
||||
|
@ -76,8 +76,7 @@ func _space_handle(m *ice.Message, safe bool, name string, conn *websocket.Conn)
|
||||
}) {
|
||||
} else if res := getSend(m, next); !m.Warn(res == nil || len(target) != 1, ice.ErrNotFound, next) {
|
||||
res.Cost(kit.Format("[%v]->%v %v %v", next, res.Optionv(ice.MSG_TARGET), res.Detailv(), msg.FormatSize()))
|
||||
m.Sleep("10ms")
|
||||
back(res, msg) // 接收响应
|
||||
back(res, msg.Sleep("10ms")) // 接收响应
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -131,9 +130,7 @@ func _space_send(m *ice.Message, space string, arg ...string) {
|
||||
_space_echo(m, []string{addSend(m, m)}, target, conn)
|
||||
}
|
||||
}), ice.ErrNotFound, space) {
|
||||
call(m, m.Config(kit.Keys(TIMEOUT, "c")), func(res *ice.Message) {
|
||||
m.Copy(res)
|
||||
})
|
||||
call(m, m.Config(kit.Keys(TIMEOUT, "c")), func(res *ice.Message) { m.Copy(res) })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,18 +44,14 @@ func (f *Frame) Start(m *ice.Message, arg ...string) bool {
|
||||
pf.Handle(route, http.StripPrefix(path.Dir(route), f))
|
||||
list[c] = path.Join(list[p], route)
|
||||
}
|
||||
m.Confm(SERVE, kit.Keym(nfs.PATH), func(key string, value string) {
|
||||
msg.Log(ROUTE, "%s <- %s <- %s", c.Name, key, value)
|
||||
f.Handle(key, http.StripPrefix(key, http.FileServer(http.Dir(value))))
|
||||
})
|
||||
for key, cmd := range c.Commands {
|
||||
if key[0] != '/' {
|
||||
if key[:1] != ice.PS {
|
||||
continue
|
||||
}
|
||||
func(key string, cmd *ice.Command) {
|
||||
msg.Log(ROUTE, "%s <- %s", c.Name, key)
|
||||
f.HandleFunc(key, func(w http.ResponseWriter, r *http.Request) {
|
||||
m.TryCatch(m.Spawn(w, r, c, cmd, key), true, func(msg *ice.Message) { _serve_handle(key, cmd, msg, w, r) })
|
||||
m.TryCatch(m.Spawn(key, cmd, c, w, r), true, func(msg *ice.Message) { _serve_handle(key, cmd, msg, w, r) })
|
||||
})
|
||||
ice.Info.Route[path.Join(list[c], key)] = ctx.FileURI(cmd.GetFileLines())
|
||||
}(key, cmd)
|
||||
@ -67,8 +63,7 @@ func (f *Frame) Start(m *ice.Message, arg ...string) bool {
|
||||
cb(f)
|
||||
default:
|
||||
m.Cmd(tcp.SERVER, tcp.LISTEN, mdb.TYPE, WEB, m.OptionSimple(mdb.NAME, tcp.HOST, tcp.PORT), func(l net.Listener) {
|
||||
mdb.HashCreate(m, m.OptionSimple(mdb.NAME, tcp.PROTO), arg, cli.STATUS, tcp.START)
|
||||
defer mdb.HashModify(m, m.OptionSimple(mdb.NAME), cli.STATUS, tcp.STOP)
|
||||
defer mdb.HashCreateDeferRemove(m, m.OptionSimple(mdb.NAME, tcp.PROTO), arg, cli.STATUS, tcp.START)()
|
||||
m.Warn(f.Server.Serve(l))
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user