{"action":"created","issue":{"url":"https://api.github.com/repos/Yawning/obfs4/issues/12","labels_url":"https://api.github.com/repos/Yawning/obfs4/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/Yawning/obfs4/issues/12/comments","events_url":"https://api.github.com/repos/Yawning/obfs4/issues/12/events","html_url":"https://github.com/Yawning/obfs4/issues/12","id":99661942,"number":12,"title":"Ease embedability by reducing main package content","user":{"login":"thomasf","id":330847,"avatar_url":"https://avatars.githubusercontent.com/u/330847?v=3","gravatar_id":"","url":"https://api.github.com/users/thomasf","html_url":"https://github.com/thomasf","followers_url":"https://api.github.com/users/thomasf/followers","following_url":"https://api.github.com/users/thomasf/following{/other_user}","gists_url":"https://api.github.com/users/thomasf/gists{/gist_id}","starred_url":"https://api.github.com/users/thomasf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomasf/subscriptions","organizations_url":"https://api.github.com/users/thomasf/orgs","repos_url":"https://api.github.com/users/thomasf/repos","events_url":"https://api.github.com/users/thomasf/events{/privacy}","received_events_url":"https://api.github.com/users/thomasf/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-07T14:48:02Z","updated_at":"2015-09-07T23:00:12Z","closed_at":"2015-09-07T23:00:12Z","body":"I'm embedding obfs4proxy inside another go program.\r\n\r\nRight now I just copied the main package to my own package, renamed the `main` functtion to `Run` and replaced everything flag related with an config struct..\r\n\r\nWould you accept a pull request moving most of the main package into `common/obfs4proxy`?\r\n\r\nIt's not super important but it does result in a nicer reuse situation.\r\n\r\nMy quick hack looks lite this:\r\n\r\n```go\r\ntype Config struct {\r\n\tShowVer       bool\r\n\tLogLevel      string\r\n\tEnableLogging bool\r\n\tUnsafeLogging bool\r\n}\r\n\r\nfunc Run(config Config) {\r\n\t// Initialize the termination state monitor as soon as possible.\r\n\ttermMon = newTermMonitor()\r\n\r\n\t// Handle the command line arguments.\r\n\t_, execName := path.Split(os.Args[0])\r\n\t// showVer := flag.Bool(\"version\", false, \"Print version and exit\")\r\n\t// logLevelStr := flag.String(\"logLevel\", \"ERROR\", \"Log level (ERROR/WARN/INFO/DEBUG)\")\r\n\t// enableLogging := flag.Bool(\"enableLogging\", false, \"Log to TOR_PT_STATE_LOCATION/\"+obfs4proxyLogFile)\r\n\t// unsafeLogging := flag.Bool(\"unsafeLogging\", false, \"Disable the address scrubber\")\r\n\t// flag.Parse()\r\n\r\n\tlogLevel := config.LogLevel\r\n\tif logLevel == \"\" {\r\n\t\tlogLevel = \"ERROR\"\r\n\t}\r\n...\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/Yawning/obfs4/issues/comments/138389856","html_url":"https://github.com/Yawning/obfs4/issues/12#issuecomment-138389856","issue_url":"https://api.github.com/repos/Yawning/obfs4/issues/12","id":138389856,"user":{"login":"Yawning","id":3646968,"avatar_url":"https://avatars.githubusercontent.com/u/3646968?v=3","gravatar_id":"","url":"https://api.github.com/users/Yawning","html_url":"https://github.com/Yawning","followers_url":"https://api.github.com/users/Yawning/followers","following_url":"https://api.github.com/users/Yawning/following{/other_user}","gists_url":"https://api.github.com/users/Yawning/gists{/gist_id}","starred_url":"https://api.github.com/users/Yawning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yawning/subscriptions","organizations_url":"https://api.github.com/users/Yawning/orgs","repos_url":"https://api.github.com/users/Yawning/repos","events_url":"https://api.github.com/users/Yawning/events{/privacy}","received_events_url":"https://api.github.com/users/Yawning/received_events","type":"User","site_admin":false},"created_at":"2015-09-07T23:00:12Z","updated_at":"2015-09-07T23:00:12Z","body":"Sorry for ignoring this for a while.  I really should just close the github issue tracker since, the only reason a copy of the code lives here is so I can keep feature branches somewhere.\r\n\r\nThis is not a use-case I want to support since the code that lives under `main` is not and will not be written with embeddability in mind (and in fact currently will do rather unexpected things when the process gets re-parented for example).\r\n\r\nI would be open to carving out things from the `main` package into sub-packages under `common` (eg: `common/socks5`, `common/termmon`) which may aid in code reuse, but the actual pt implementation already provides a well defined external interface based on `fork() + exec()`, and that's all I'm currently willing to support."}}