(f *ProxyFrame)
| 154 | } |
| 155 | |
| 156 | func (o *Outputer) processOpenFrame(f *ProxyFrame) { |
| 157 | |
| 158 | id := f.OpenFrame.Id |
| 159 | targetAddr := f.OpenFrame.Toaddr |
| 160 | |
| 161 | rf := &ProxyFrame{} |
| 162 | rf.Type = FRAME_TYPE_OPENRSP |
| 163 | rf.OpenRspFrame = &OpenConnRspFrame{} |
| 164 | rf.OpenRspFrame.Id = id |
| 165 | rf.OpenRspFrame.Ret = false |
| 166 | |
| 167 | if o.ss { |
| 168 | ss_local_host := os.Getenv("SS_LOCAL_HOST") |
| 169 | ss_local_port := os.Getenv("SS_LOCAL_PORT") |
| 170 | if len(ss_local_host) <= 0 || len(ss_local_port) <= 0 { |
| 171 | rf.OpenRspFrame.Msg = "ss no env" |
| 172 | o.father.sendch.Write(rf) |
| 173 | loggo.Info("Outputer ss no env %s %s", ss_local_host, ss_local_port) |
| 174 | return |
| 175 | } |
| 176 | targetAddr = ss_local_host + ":" + ss_local_port |
| 177 | } |
| 178 | |
| 179 | size := o.sonnySize() |
| 180 | if size >= o.config.MaxSonny { |
| 181 | rf.OpenRspFrame.Msg = "max sonny" |
| 182 | o.father.sendch.Write(rf) |
| 183 | loggo.Info("Outputer listen max sonny %s %d", id, size) |
| 184 | return |
| 185 | } |
| 186 | |
| 187 | proxyconn := &ProxyConn{id: id, conn: nil, established: true} |
| 188 | _, loaded := o.sonny.LoadOrStore(proxyconn.id, proxyconn) |
| 189 | if loaded { |
| 190 | rf.OpenRspFrame.Msg = "Conn id fail" |
| 191 | o.father.sendch.Write(rf) |
| 192 | loggo.Error("Outputer processOpenFrame LoadOrStore fail %s %s", targetAddr, id) |
| 193 | return |
| 194 | } |
| 195 | |
| 196 | sendch := common.NewChannel(o.config.ConnBuffer) |
| 197 | recvch := common.NewChannel(o.config.ConnBuffer) |
| 198 | |
| 199 | proxyconn.sendch = sendch |
| 200 | proxyconn.recvch = recvch |
| 201 | |
| 202 | o.fwg.Go("Outputer processProxyConn"+" "+targetAddr, func() error { |
| 203 | atomic.AddInt32(&gStateThreadNum.OutputerSonnyThread, 1) |
| 204 | defer atomic.AddInt32(&gStateThreadNum.OutputerSonnyThread, -1) |
| 205 | return o.processProxyConn(proxyconn, targetAddr) |
| 206 | }) |
| 207 | } |
| 208 | |
| 209 | func (o *Outputer) processProxyConn(proxyConn *ProxyConn, targetAddr string) error { |
| 210 |
no test coverage detected