-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from koron/proxy-set
Proxy set
- Loading branch information
Showing
8 changed files
with
481 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package dproxy | ||
|
||
type frame interface { | ||
// parentFrame returns parent frame. | ||
parentFrame() frame | ||
// frameLabel return label of frame. | ||
frameLabel() string | ||
} | ||
|
||
func fullAddress(f frame) string { | ||
x := 0 | ||
for g := f; g != nil; g = g.parentFrame() { | ||
x += len(g.frameLabel()) | ||
} | ||
b := make([]byte, x) | ||
for g := f; g != nil; g = g.parentFrame() { | ||
x -= len(g.frameLabel()) | ||
copy(b[x:], g.frameLabel()) | ||
} | ||
if b[0] == '.' { | ||
return string(b[1:]) | ||
} | ||
return string(b) | ||
} | ||
|
||
type simpleFrame struct { | ||
parent frame | ||
label string | ||
} | ||
|
||
var _ frame = (*simpleFrame)(nil) | ||
|
||
func (f *simpleFrame) parentFrame() frame { | ||
return f.parent | ||
} | ||
|
||
func (f *simpleFrame) frameLabel() string { | ||
return f.label | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.