From 8f1c9ba3524dbbf333fad79577aec8596a432e6e Mon Sep 17 00:00:00 2001 From: jiyoungcheon Date: Fri, 1 Nov 2024 01:27:57 -0400 Subject: [PATCH] first commit --- go.mod | 52 ++++++ go.sum | 169 ++++++++++++++++++++ icsbatch/batch_everyday.go | 44 ++++++ icsconf/icsconf.go | 62 ++++++++ icsencry/encryption.go | 96 +++++++++++ icserror/icserror.go | 71 +++++++++ icserror/icserror_test.go | 18 +++ icserror/icserrordef.go | 315 +++++++++++++++++++++++++++++++++++++ icshttp/http_request.go | 33 ++++ icslog/icslog.go | 35 +++++ main.go | 15 ++ 11 files changed, 910 insertions(+) create mode 100644 go.mod create mode 100644 go.sum create mode 100644 icsbatch/batch_everyday.go create mode 100644 icsconf/icsconf.go create mode 100644 icsencry/encryption.go create mode 100644 icserror/icserror.go create mode 100644 icserror/icserror_test.go create mode 100644 icserror/icserrordef.go create mode 100644 icshttp/http_request.go create mode 100644 icslog/icslog.go create mode 100644 main.go diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..f748bd0 --- /dev/null +++ b/go.mod @@ -0,0 +1,52 @@ +module mybatch + +go 1.22.0 + +require ( + cloud.google.com/go/speech v1.25.1 + github.com/google/uuid v1.6.0 + github.com/stretchr/testify v1.9.0 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +require ( + cloud.google.com/go v0.116.0 // indirect + cloud.google.com/go/auth v0.9.3 // indirect + cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect + cloud.google.com/go/compute/metadata v0.5.0 // indirect + cloud.google.com/go/longrunning v0.6.1 // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/google/s2a-go v0.1.8 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect + github.com/googleapis/gax-go/v2 v2.13.0 // indirect + github.com/gorilla/websocket v1.5.3 + github.com/robfig/cron/v3 v3.0.1 + go.opencensus.io v0.24.0 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect + go.opentelemetry.io/otel v1.29.0 // indirect + go.opentelemetry.io/otel/metric v1.29.0 // indirect + go.opentelemetry.io/otel/trace v1.29.0 // indirect + golang.org/x/crypto v0.27.0 + golang.org/x/net v0.29.0 // indirect + golang.org/x/oauth2 v0.23.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/text v0.18.0 // indirect + golang.org/x/time v0.6.0 // indirect + google.golang.org/api v0.197.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect + google.golang.org/grpc v1.67.1 // indirect + google.golang.org/protobuf v1.35.1 // indirect +) + +replace git.icomsys.co.kr/icomsys/voicegateway/config => ../config diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..2e09a5e --- /dev/null +++ b/go.sum @@ -0,0 +1,169 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.116.0 h1:B3fRrSDkLRt5qSHWe40ERJvhvnQwdZiHu0bJOpldweE= +cloud.google.com/go v0.116.0/go.mod h1:cEPSRWPzZEswwdr9BxE6ChEn01dWlTaF05LiC2Xs70U= +cloud.google.com/go/auth v0.9.3 h1:VOEUIAADkkLtyfr3BLa3R8Ed/j6w1jTBmARx+wb5w5U= +cloud.google.com/go/auth v0.9.3/go.mod h1:7z6VY+7h3KUdRov5F1i8NDP5ZzWKYmEPO842BgCsmTk= +cloud.google.com/go/auth/oauth2adapt v0.2.4 h1:0GWE/FUsXhf6C+jAkWgYm7X9tK8cuEIfy19DBn6B6bY= +cloud.google.com/go/auth/oauth2adapt v0.2.4/go.mod h1:jC/jOpwFP6JBxhB3P5Rr0a9HLMC/Pe3eaL4NmdvqPtc= +cloud.google.com/go/compute/metadata v0.5.0 h1:Zr0eK8JbFv6+Wi4ilXAR8FJ3wyNdpxHKJNPos6LTZOY= +cloud.google.com/go/compute/metadata v0.5.0/go.mod h1:aHnloV2TPI38yx4s9+wAZhHykWvVCfu7hQbF+9CWoiY= +cloud.google.com/go/longrunning v0.6.1 h1:lOLTFxYpr8hcRtcwWir5ITh1PAKUD/sG2lKrTSYjyMc= +cloud.google.com/go/longrunning v0.6.1/go.mod h1:nHISoOZpBcmlwbJmiVk5oDRz0qG/ZxPynEGs1iZ79s0= +cloud.google.com/go/speech v1.25.1 h1:iGZJS3wrdkje/Vqiacx1+r+zVwUZoXVMdklYIVsvfNw= +cloud.google.com/go/speech v1.25.1/go.mod h1:WgQghvghkZ1htG6BhYn98mP7Tg0mti8dBFDLMVXH/vM= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= +github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/s2a-go v0.1.8 h1:zZDs9gcbt9ZPLV0ndSyQk6Kacx2g/X+SKYovpnz3SMM= +github.com/google/s2a-go v0.1.8/go.mod h1:6iNWHTpQ+nfNRN5E00MSdfDwVesa8hhS32PhPO8deJA= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/enterprise-certificate-proxy v0.3.4 h1:XYIDZApgAnrN1c855gTgghdIA6Stxb52D5RnLI1SLyw= +github.com/googleapis/enterprise-certificate-proxy v0.3.4/go.mod h1:YKe7cfqYXjKGpGvmSg28/fFvhNzinZQm8DGnaburhGA= +github.com/googleapis/gax-go/v2 v2.13.0 h1:yitjD5f7jQHhyDsnhKEBU52NdvvdSeGzlAnDPT0hH1s= +github.com/googleapis/gax-go/v2 v2.13.0/go.mod h1:Z/fvTZXF8/uw7Xu5GuslPw+bplx6SS338j1Is2S+B7A= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= +github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= +go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 h1:r6I7RJCN86bpD/FQwedZ0vSixDpwuWREjW9oRMsmqDc= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0/go.mod h1:B9yO6b04uB80CzjedvewuqDhxJxi11s7/GtiGa8bAjI= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0/go.mod h1:L7UH0GbB0p47T4Rri3uHjbpCFYrVrwc1I25QhNPiGK8= +go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw= +go.opentelemetry.io/otel v1.29.0/go.mod h1:N/WtXPs1CNCUEx+Agz5uouwCba+i+bJGFicT8SR4NP8= +go.opentelemetry.io/otel/metric v1.29.0 h1:vPf/HFWTNkPu1aYeIsc98l4ktOQaL6LeSoeV2g+8YLc= +go.opentelemetry.io/otel/metric v1.29.0/go.mod h1:auu/QWieFVWx+DmQOUMgj0F8LHWdgalxXqvp7BII/W8= +go.opentelemetry.io/otel/trace v1.29.0 h1:J/8ZNK4XgR7a21DZUAsbF8pZ5Jcw1VhACmnYt39JTi4= +go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= +golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U= +golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.197.0 h1:x6CwqQLsFiA5JKAiGyGBjc2bNtHtLddhJCE2IKuhhcQ= +google.golang.org/api v0.197.0/go.mod h1:AuOuo20GoQ331nq7DquGHlU6d+2wN2fZ8O0ta60nRNw= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53 h1:fVoAXEKA4+yufmbdVYv+SE73+cPZbbbe8paLsHfkK+U= +google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53/go.mod h1:riSXTwQ4+nqmPGtobMFyW5FqVAmIs0St6VPp4Ug7CE4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1:X58yt85/IXCx0Y3ZwN6sEIKZzQtDEYaBWrDvErdXrRE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= +google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/icsbatch/batch_everyday.go b/icsbatch/batch_everyday.go new file mode 100644 index 0000000..65995aa --- /dev/null +++ b/icsbatch/batch_everyday.go @@ -0,0 +1,44 @@ +package icsbatch + +import ( + "fmt" + stt "mybatch/icsstt" + + "github.com/robfig/cron/v3" +) + +func BatchForPostRequestForDataList() { + cronInstance := cron.New() + + _, err := cronInstance.AddFunc("0 1 * * *", func() { + fmt.Println("매일 새벽 1시: ProcessPostRequestForDataList 실행") + stt.ProcessPostRequestForDataList() + }) + + if err != nil { + fmt.Println("스케줄 추가 오류:", err) + return + } + + cronInstance.Start() + + select {} +} + +func BatchForPostRequestForDataListTest() { + cronInstance := cron.New() + + _, err := cronInstance.AddFunc("@every 20s", func() { + stt.ProcessPostRequestForDataList() + }) + + if err != nil { + fmt.Println("스케줄 추가 오류:", err) + return + } + + cronInstance.Start() + + select {} + +} diff --git a/icsconf/icsconf.go b/icsconf/icsconf.go new file mode 100644 index 0000000..0f76bff --- /dev/null +++ b/icsconf/icsconf.go @@ -0,0 +1,62 @@ +package icsconf + +import ( + "encoding/xml" + "fmt" + "os" + "sync" +) + +type AppInfo struct { + XMLName xml.Name `xml:"AppInfo"` + Speech Speech `xml:"Speech"` + Directories Directories `xml:"Directories"` + STT STTConf `xml:"STT"` +} + +type Speech struct { + Package string `xml:"Package"` + ProtoPackage string `xml:"ProtoPackage"` +} + +type Directories struct { + PCMDirectory string `xml:"PCMDirectory"` + WAVDirectory string `xml:"WAVDirectory"` + LOGDirectory string `xml:"LOGDirectory"` + RecDirectory string `xml:"RecDirectory"` +} + +type STTConf struct { + Value string `xml:"value,attr"` + Name string `xml:"name,attr"` + Port string `xml:"port,attr"` + SrcIP string `xml:"srcIP,attr"` +} + +var ( + once sync.Once + appInfo AppInfo +) + +func loadConfig() { + file, err := os.Open("/home/prac/svc/icsbc/Appinfo.xml") + if err != nil { + fmt.Println("failed to open config file: ", err) + return + } + defer file.Close() + + if err := xml.NewDecoder(file).Decode(&appInfo); err != nil { + fmt.Println("failed to decode XML: ", err) + return + } +} + +func initConfig() { + once.Do(loadConfig) +} + +func Getconfig() AppInfo { + initConfig() + return appInfo +} diff --git a/icsencry/encryption.go b/icsencry/encryption.go new file mode 100644 index 0000000..da03c61 --- /dev/null +++ b/icsencry/encryption.go @@ -0,0 +1,96 @@ +package encry + +import ( + "bytes" + "crypto/aes" + "crypto/cipher" + "crypto/rand" + "crypto/sha256" + "encoding/base64" + "fmt" + "io" + "log" + + "golang.org/x/crypto/pbkdf2" +) + +func Encrypting(jsonData []byte) (encryptedData string) { + + encryptedData, err := EncryptAES256(jsonData, secretKey) + if err != nil { + log.Fatalf("failed to encrypt data: %v", err) + } + + return encryptedData +} + +var secretKey = []byte("icomsys1234") + +func pkcs7Padding(data []byte, blockSize int) []byte { + padding := blockSize - len(data)%blockSize + padtext := bytes.Repeat([]byte{byte(padding)}, padding) + return append(data, padtext...) +} + +func pkcs7Unpadding(data []byte) ([]byte, error) { + length := len(data) + if length == 0 { + return nil, fmt.Errorf("invalid padding size") + } + padding := int(data[length-1]) + if padding > length { + return nil, fmt.Errorf("invalid padding size") + } + return data[:length-padding], nil +} + +func EncryptAES256(plaintext []byte, passphrase []byte) (string, error) { + key := pbkdf2.Key(passphrase, []byte("salt"), 4096, 32, sha256.New) + block, err := aes.NewCipher(key) + if err != nil { + return "", err + } + + plaintext = pkcs7Padding(plaintext, aes.BlockSize) + + ciphertext := make([]byte, aes.BlockSize+len(plaintext)) + iv := ciphertext[:aes.BlockSize] + if _, err := io.ReadFull(rand.Reader, iv); err != nil { + return "", err + } + + stream := cipher.NewCBCEncrypter(block, iv) + stream.CryptBlocks(ciphertext[aes.BlockSize:], plaintext) + + return base64.URLEncoding.EncodeToString(ciphertext), nil +} + +func DecryptAES256(ciphertext string, passphrase []byte) ([]byte, error) { + key := pbkdf2.Key(passphrase, []byte("salt"), 4096, 32, sha256.New) + decoded, err := base64.URLEncoding.DecodeString(ciphertext) + if err != nil { + return nil, err + } + + block, err := aes.NewCipher(key) + if err != nil { + return nil, err + } + + if len(decoded) < aes.BlockSize { + return nil, fmt.Errorf("ciphertext too short") + } + + iv := decoded[:aes.BlockSize] + decoded = decoded[aes.BlockSize:] + + stream := cipher.NewCBCDecrypter(block, iv) + stream.CryptBlocks(decoded, decoded) + + decoded, err = pkcs7Unpadding(decoded) + if err != nil { + return nil, err + } + + return decoded, nil +} diff --git a/icserror/icserror.go b/icserror/icserror.go new file mode 100644 index 0000000..d975f0c --- /dev/null +++ b/icserror/icserror.go @@ -0,0 +1,71 @@ +// error system package +package icserror + +import ( + "errors" + "fmt" + "runtime" + "strings" +) + +type IcsError struct { + code interface{} + message string + err error +} + +// Error implements error. +func (e *IcsError) Error() string { + panic("unimplemented") +} + +func GetModName() string { + return "icserror" +} + +func NewIcsError(errString string, code interface{}) *IcsError { + var err IcsError + err.err = errors.New(errString) + err.code = code + err.message = errString + + return &err +} + +func (e IcsError) String() string { + return fmt.Sprintf("Message: %s, Code: %v, Error: %v\n", e.message, e.code, e.err) +} + +func (e IcsError) PrintWithCaller(depth int) { + errstr := fmt.Sprintf("Code: %v, Message: %s", e.code, e.message) + funcname, file, line, ok := runtime.Caller(depth) + if ok { + files := strings.Split(file, "/") + fileslen := len(files) + func1 := runtime.FuncForPC(funcname).Name() + funcs := strings.Split(func1, "/") + funcslen := len(funcs) + + fmt.Printf("[%s:%d %s] %s\n", files[fileslen-1], line, funcs[funcslen-1], errstr) + } +} + +func (e IcsError) Equal(i *IcsError) bool { + return e.code == i.code +} + +func (e *IcsError) SetError(baseError error) { + e.err = baseError +} + +func (e *IcsError) GetCode() interface{} { + return e.code +} + +func (e *IcsError) GetMessage() string { + return e.message +} + +func (e *IcsError) GetError() error { + return e.err +} diff --git a/icserror/icserror_test.go b/icserror/icserror_test.go new file mode 100644 index 0000000..6399ebc --- /dev/null +++ b/icserror/icserror_test.go @@ -0,0 +1,18 @@ +package icserror + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestGetModName(t *testing.T) { + got := GetModName() + assert.Equal(t, "icserror", got, "not expected value") + + g1 := NewIcsError("Test", 0) + g2 := NewIcsError("Test", 0) + assert.Equal(t, g1, g2, "not expected value") + + assert.Equal(t, g1.Equal(g2), true, "not expected value") +} diff --git a/icserror/icserrordef.go b/icserror/icserrordef.go new file mode 100644 index 0000000..74f02ea --- /dev/null +++ b/icserror/icserrordef.go @@ -0,0 +1,315 @@ +package icserror + +const ( + ICS_ERROR_COMMON = iota + ICS_ERROR_CONFIG = ICS_ERROR_COMMON + 1000 + ICS_ERROR_SVC = ICS_ERROR_COMMON + 2000 + ICS_ERROR_UTIL = ICS_ERROR_COMMON + 2500 + ICS_ERROR_APP = ICS_ERROR_COMMON + 3000 + ICS_ERROR_DB = ICS_ERROR_COMMON + 3500 + ICS_ERROR_NET = ICS_ERROR_COMMON + 4000 + ICS_ERROR_RECORDDATA = ICS_ERROR_COMMON + 4500 + ICS_ERROR_TTS = ICS_ERROR_COMMON + 5000 + ICS_ERROR_STT = ICS_ERROR_COMMON + 5500 + ICS_ERROR_WEBSOCKET = ICS_ERROR_COMMON + 6000 + ICS_ERROR_SIP_PARSER = ICS_ERROR_COMMON + 6500 + ICS_ERROR_SDP_PARSER = ICS_ERROR_COMMON + 7000 + ICS_ERROR_RTP_PARSER = ICS_ERROR_COMMON + 7500 + ICS_ERROR_CONV = ICS_ERROR_COMMON + 8000 + ICS_ERROR_SESS = ICS_ERROR_COMMON + 8500 + ICS_ERROR_EVENT = ICS_ERROR_COMMON + 9000 + ICS_ERROR_HTTP_CLIENT = ICS_ERROR_COMMON + 9500 + ICS_ERROR_STTMSG_PARSER = ICS_ERROR_COMMON + 10000 + ICS_ERROR_STTUDP_PARSER = ICS_ERROR_COMMON + 10500 + ICS_ERROR_TTS_PARSER = ICS_ERROR_COMMON + 11000 + ICS_ERROR_S3 = ICS_ERROR_COMMON + 11500 +) + +// common error +const ( + ICSOK = iota + ICS_ERROR_COMMON + ICSFALSE + ICS_ERROR_NOTFOUND_HOME + ICS_ERROR_INVALID_PARAM + ICS_ERROR_FILE_OPEN + ICS_ERROR_MAKE_DIR + ICS_ERROR_WRITE_FILE + ICS_ERROR_STRING_CONV + ICS_ERROR_DAEMONIZE + ICS_ERROR_INVALID_DATA +) + +var ( + ICSERRTest = NewIcsError("This Is Error Test", ICSOK) + ICSERRNotFoundHome = NewIcsError("Not found HOME Directory", ICS_ERROR_NOTFOUND_HOME) + ICSERRInvalidParam = NewIcsError("Invalid Parameter", ICS_ERROR_INVALID_PARAM) + ICSERRFileOpen = NewIcsError("File Open Error", ICS_ERROR_FILE_OPEN) + ICSERRMakeDir = NewIcsError("Make Dir Error", ICS_ERROR_MAKE_DIR) + ICSERRWriteFile = NewIcsError("File Write Error", ICS_ERROR_WRITE_FILE) + ICSERRStrConv = NewIcsError("Atoi Error", ICS_ERROR_STRING_CONV) + ICSERRDeamonize = NewIcsError("Process Deamonize Error", ICS_ERROR_DAEMONIZE) + ICSERRInvalidData = NewIcsError("There is not valid data", ICS_ERROR_INVALID_DATA) +) + +// config error +const ( + ICS_ERROR_CONFIG_FILE_NOTFOUND = iota + ICS_ERROR_CONFIG + ICS_ERROR_CONFIG_OPEN_FILE + ICS_ERROR_CONFIG_UNMARSHAL +) + +var ( + ICSERRCONFFileNotFound = NewIcsError("icsconfig: Not Found The Config File ", ICS_ERROR_CONFIG_FILE_NOTFOUND) + ICSERRCONFOpenFile = NewIcsError("icsconfig: Configuration File Open Error", ICS_ERROR_CONFIG_OPEN_FILE) + ICSERRCONFUnmarshal = NewIcsError("icsconfig: Config File Unmarshal Error", ICS_ERROR_CONFIG_UNMARSHAL) +) + +// service error +const ( + ICS_ERROR_SVC_WRONG_TIME = iota + ICS_ERROR_SVC +) + +var ( + ICSERRSVCTime = NewIcsError("icsservice: Wrong time", ICS_ERROR_SVC_WRONG_TIME) +) + +// util error +const ( + ICS_ERROR_UTIL_DISK_FULL = iota + ICS_ERROR_UTIL +) + +var ( + ICSERRUTILDiskFull = NewIcsError("icsutil: Disk Full", ICS_ERROR_UTIL_DISK_FULL) +) + +// app error +const ( + ICS_ERROR_APP_HTTP = iota + ICS_ERROR_APP +) + +var ( + ICSERRAPPHTTP = NewIcsError("icsapp: HTTP Listen", ICS_ERROR_APP_HTTP) +) + +const ( + ICS_ERROR_DB_OPEN = iota + ICS_ERROR_DB + ICS_ERROR_DB_CLOSE + ICS_ERROR_DB_INIT + ICS_ERROR_DB_WRITE +) + +var ( + ICSERRDBOpen = NewIcsError("icsdb: DB Open Error", ICS_ERROR_DB_OPEN) + ICSERRDBClose = NewIcsError("icsdb: DB Close Error", ICS_ERROR_DB_CLOSE) + ICSERRDBNotInit = NewIcsError("icsdb: DB Not Initialized", ICS_ERROR_DB_INIT) + ICSERRDBWrite = NewIcsError("icsdb: Write Error", ICS_ERROR_DB_WRITE) +) + +// net error +const ( + ICS_ERROR_NET_RESOLVEADDR = iota + ICS_ERROR_NET + ICS_ERROR_NET_LISTEN + ICS_ERROR_NET_CONNECT + ICS_ERROR_NET_NOT_CONNECTED + ICS_ERROR_NET_CLOSE + ICS_ERROR_NET_WRITE + ICS_ERROR_NET_READ + ICS_ERROR_NET_ACCEPT + ICS_ERROR_NET_NOT_FOUND_IF + ICS_ERROR_NET_GET_ADDR +) + +var ( + ICSERRNETResolveAddrError = NewIcsError("icsnet: Resolve Address Error", ICS_ERROR_NET_RESOLVEADDR) + ICSERRNETListenError = NewIcsError("icsnet: Listen Error", ICS_ERROR_NET_LISTEN) + ICSERRNETConnectError = NewIcsError("icsnet: Connect Error", ICS_ERROR_NET_CONNECT) + ICSERRNETNotConnectError = NewIcsError("icsnet: Connection is not completed yet", ICS_ERROR_NET_NOT_CONNECTED) + ICSERRNETCloseError = NewIcsError("icsnet: Close Error", ICS_ERROR_NET_CLOSE) + ICSERRNETWriteError = NewIcsError("icsnet: Write Error", ICS_ERROR_NET_WRITE) + ICSERRNETReadError = NewIcsError("icsnet: Read Error", ICS_ERROR_NET_READ) + ICSERRNETAcceptError = NewIcsError("icsnet: Accept Error", ICS_ERROR_NET_ACCEPT) + ICSERRNETNotFoundIF = NewIcsError("icsnet: Not Found Interface", ICS_ERROR_NET_NOT_FOUND_IF) + ICSERRNETGetAddr = NewIcsError("icsnet: Could Not Get Address", ICS_ERROR_NET_GET_ADDR) +) + +// recorddata error +const ( + ICS_ERROR_RECORDDATA_CALLSIGNAL_PARSING = iota + ICS_ERROR_RECORDDATA +) + +var ( + ICSERRRECORDDATAParsing = NewIcsError("recorddata: Parsing Error", ICS_ERROR_RECORDDATA_CALLSIGNAL_PARSING) +) + +// tts error +const ( + ICS_ERROR_TTS_CONTINUE = iota + ICS_ERROR_TTS + ICS_ERROR_TTS_OK + ICS_ERROR_TTS_FAIL + ICS_ERROR_TTS_FAIL_EINTR + ICS_ERROR_TTS_FAIL_EMPTY + ICS_ERROR_TTS_FAIL_INITIALIZE + ICS_ERROR_TTS_NOT_INITIALIZE + ICS_ERROR_TTS_ALREADY_CLOSED + ICS_ERROR_TTS_MP3_CONV +) + +var ( + ICSERRTTSContinue = NewIcsError("tts: Processing Synthesis", ICS_ERROR_TTS_CONTINUE) + ICSERRTTSOK = NewIcsError("tts: Synthesis Completed", ICS_ERROR_TTS_OK) + ICSERRTTSFail = NewIcsError("tts: Synthesis Failed", ICS_ERROR_TTS_FAIL) + ICSERRTTSFailEINTR = NewIcsError("tts: Synthesis Failed. Interrupted System Call", ICS_ERROR_TTS_FAIL_EINTR) + ICSERRTTSFailEmpty = NewIcsError("tts: Synthesis Failed. No Voice", ICS_ERROR_TTS_FAIL_EMPTY) + ICSERRTTSFailInit = NewIcsError("tts: Initialized Error", ICS_ERROR_TTS_FAIL_INITIALIZE) + ICSERRTTSNotInit = NewIcsError("tts: Not Initialized ", ICS_ERROR_TTS_NOT_INITIALIZE) + ICSERRTTSAlreadyClosed = NewIcsError("tts: Already Closed ", ICS_ERROR_TTS_ALREADY_CLOSED) + ICSERRTTSMP3Conv = NewIcsError("tts: MP3 Decoding Error", ICS_ERROR_TTS_MP3_CONV) +) + +// stt error +const ( + ICS_ERROR_STT_CONTINUE = iota + ICS_ERROR_STT + ICS_ERROR_STT_BARGEIN + ICS_ERROR_STT_OK + ICS_ERROR_STT_FAIL + ICS_ERROR_STT_FAIL_EMPTY + ICS_ERROR_STT_SEND_FAIL + ICS_ERROR_STT_FAIL_INITIALIZE + ICS_ERROR_STT_CONNECT_TIMEOUT + ICS_ERROR_STT_CONNECT_FAIL + ICS_ERROR_STT_CONNECT_CLOSE_FAIL + ICS_ERROR_STT_NOT_INITIALIZE + ICS_ERROR_STT_FREE_ERROR + ICS_ERROR_STT_ALREADY_CLOSED + ICS_ERROR_STT_LANGUAGE_SETTING +) + +var ( + ICSERRSTTContinue = NewIcsError("stt: Processing Recognition", ICS_ERROR_STT_CONTINUE) + ICSERRSTTBargeIn = NewIcsError("stt: Barge-In Occurred", ICS_ERROR_STT_BARGEIN) + ICSERRSTTOK = NewIcsError("stt: Recognition Completed", ICS_ERROR_STT_OK) + ICSERRSTTFail = NewIcsError("stt: Recoognition Failed", ICS_ERROR_STT_FAIL) + ICSERRSTTFailEmpty = NewIcsError("stt: Recoognition Failed. No Voice", ICS_ERROR_STT_FAIL_EMPTY) + ICSERRSTTSendFail = NewIcsError("stt: Initialized Error", ICS_ERROR_STT_SEND_FAIL) + ICSERRSTTFailInit = NewIcsError("stt: Initialized Error", ICS_ERROR_STT_FAIL_INITIALIZE) + ICSERRSTTConnectTimeout = NewIcsError("stt: Connection timeout", ICS_ERROR_STT_CONNECT_TIMEOUT) + ICSERRSTTConnectFail = NewIcsError("stt: Connection timeout", ICS_ERROR_STT_CONNECT_FAIL) + ICSERRSTTConnectCloseFail = NewIcsError("stt: Connection close fail", ICS_ERROR_STT_CONNECT_CLOSE_FAIL) + ICSERRSTTNotInit = NewIcsError("stt: Not Initialized ", ICS_ERROR_STT_NOT_INITIALIZE) + ICSERRSTTFreeError = NewIcsError("stt: Free Error ", ICS_ERROR_STT_FREE_ERROR) + ICSERRSTTAlreadyClosed = NewIcsError("stt: Already Closed ", ICS_ERROR_STT_ALREADY_CLOSED) + ICSERRSTTLanguageSetting = NewIcsError("stt: Language Setting Failed ", ICS_ERROR_STT_LANGUAGE_SETTING) +) + +// websocket error +const ( + ICS_ERROR_WEBSOCKET_CONNECT_FAIL = iota + ICS_ERROR_WEBSOCKET + ICS_ERROR_WEBSOCKET_NOT_CONNECT + ICS_ERROR_WEBSOCKET_CLOSE + ICS_ERROR_WEBSOCKET_READ + ICS_ERROR_WEBSOCKET_WRITE + ICS_ERROR_WEBSOCKET_NOT_SUPPORTED_MSG_TYPE +) + +var ( + ICSERRWEBSOCKETConnectFailError = NewIcsError("icsws: Failed to Connect to host", ICS_ERROR_WEBSOCKET_CONNECT_FAIL) + ICSERRWEBSOCKETNotConnectError = NewIcsError("icsws: Not Connected Yet", ICS_ERROR_WEBSOCKET_NOT_CONNECT) + ICSERRWEBSOCKETNotClose = NewIcsError("icsws: Could Not Close", ICS_ERROR_WEBSOCKET_CLOSE) + ICSERRWEBSOCKETReadError = NewIcsError("icsws: Failed to Read", ICS_ERROR_WEBSOCKET_READ) + ICSERRWEBSOCKETWriteError = NewIcsError("icsws: Failed to Write", ICS_ERROR_WEBSOCKET_WRITE) + ICSERRWEBSOCKETSupportedMsgType = NewIcsError("icsws: Failed to Write", ICS_ERROR_WEBSOCKET_NOT_SUPPORTED_MSG_TYPE) +) + +// sip parsing error +var ( + ICSERRSIPHeader = NewIcsError("icssip: Header format Error", ICS_ERROR_SIP_PARSER) + ICSERRINVITERequired = NewIcsError("icssip: INVITE Method required SDP", ICS_ERROR_SIP_PARSER) + ICSERR200OKRequired = NewIcsError("icssip: 200 OK Method required SDP", ICS_ERROR_SIP_PARSER) +) + +// sdp parsing error +var ( + ICSERRSDPParser = NewIcsError("icssdp: Data parser Error", ICS_ERROR_SDP_PARSER) + ICSERRNotFoundSdpMedia = NewIcsError("icssdp: Not Found SDP Media audio tag", ICS_ERROR_SDP_PARSER) + ICSERRSDPAudiotagPortValue = NewIcsError("icssdp: SDP Media audio tag port is not numeric", ICS_ERROR_SDP_PARSER) +) + +// rtp parser error +const ( + ICS_ERROR_RTP_NO = iota + ICS_ERROR_RTP_PARSER +) + +var ( + ICSERRRTPNo = NewIcsError("icsrtp: This packet may be not RTP", ICS_ERROR_RTP_NO) +) + +// media converter error +const ( + ICS_ERROR_CONV_NOT_SUPPORTED_CODEC = iota + ICS_ERROR_CONV + ICS_ERROR_CONV_DECODE +) + +var ( + ICSERRCONVNotSupportedCodec = NewIcsError("icsmediaconv: Not Supported codec", ICS_ERROR_CONV_NOT_SUPPORTED_CODEC) + ICSERRCONVDecodeFail = NewIcsError("icsmediaconv: Decoding Fail", ICS_ERROR_CONV_DECODE) +) + +// session error +const ( + ICS_ERROR_SESS_NOT_FOUND_SESSION = iota + ICS_ERROR_SESS + ICS_ERROR_SESS_SESSION_MAX_IDLE + ICS_ERROR_SESS_SESSION_NUM_EXCEED +) + +var ( + ICSERRSESSNotFoundSession = NewIcsError("icssessionmanager: Not Found Session", ICS_ERROR_SESS_NOT_FOUND_SESSION) + ICSERRSESSMaxSessionIdle = NewIcsError("icssessionmanager: Exceeded Session Max Idling Time", ICS_ERROR_SESS_SESSION_MAX_IDLE) + ICSERRSESSMaxSessionNumber = NewIcsError("icssessionmanager: Licensed Channel Number Exceeded ", ICS_ERROR_SESS_SESSION_NUM_EXCEED) +) + +// event error +const ( + ICS_ERROR_EVT_ALLOC = iota + ICS_ERROR_EVENT + ICS_ERROR_EVT_REMOVE + ICS_ERROR_EVT_POST + ICS_ERROR_EVT_NOT_INITIALIZE + ICS_ERROR_EVT_UNKNOWN +) + +var ( + ICSERREVTAlloc = NewIcsError("icsevent: Event Allocation Error", ICS_ERROR_EVT_ALLOC) + ICSERREVTRemove = NewIcsError("icsevent: Event Remove Error", ICS_ERROR_EVT_REMOVE) + ICSERREVTPost = NewIcsError("icsevent: Event Post Error", ICS_ERROR_EVT_POST) + ICSERREVTNotInit = NewIcsError("icsevent: Event System Not Initialized", ICS_ERROR_EVT_NOT_INITIALIZE) + ICSERREVTUnkown = NewIcsError("icsevent: Unkown Error", ICS_ERROR_EVT_UNKNOWN) +) + +// http client +const ( + ICS_ERROR_HTTP_CLIENT_RESPONSE = iota + ICS_ERROR_HTTP_CLIENT + ICS_ERROR_HTTP_CLIENT_CREATE + ICS_ERROR_HTTP_CLIENT_MARSHAL + ICS_ERROR_HTTP_CLIENT_UNMARSHAL + ICS_ERROR_HTTP_CLIENT_EXCUTION + ICS_ERROR_HTTP_CLIENT_READBODY +) + +var ( + ICSERRHTTPClientResponse = NewIcsError("icshttpclient: No Response", ICS_ERROR_HTTP_CLIENT_RESPONSE) + ICSERRHTTPClientCreate = NewIcsError("icshttpclient: http.NewRequest", ICS_ERROR_HTTP_CLIENT_CREATE) + ICSERRHTTPClientMarshal = NewIcsError("icshttpclient: Data Marshal", ICS_ERROR_HTTP_CLIENT_MARSHAL) + ICSERRHTTPClientUnmarshal = NewIcsError("icshttpclient: Data Unmarshal", ICS_ERROR_HTTP_CLIENT_UNMARSHAL) + ICSERRHTTPClientExcecution = NewIcsError("icshttpclient: Request http", ICS_ERROR_HTTP_CLIENT_EXCUTION) + ICSERRHTTPClientReadBody = NewIcsError("icshttpclient: Read Response Body", ICS_ERROR_HTTP_CLIENT_READBODY) +) + +// s3 +const ( + ICS_ERROR_S3_CONNECT = iota + ICS_ERROR_S3 + ICS_ERROR_S3_WRITE +) + +var ( + ICSERRORS3Connect = NewIcsError("icsaws: Connect error", ICS_ERROR_S3_CONNECT) + ICSERRORS3Write = NewIcsError("icsaws: File Write error", ICS_ERROR_S3_WRITE) +) diff --git a/icshttp/http_request.go b/icshttp/http_request.go new file mode 100644 index 0000000..5b34be9 --- /dev/null +++ b/icshttp/http_request.go @@ -0,0 +1,33 @@ +package httprequest + +import ( + "crypto/tls" + "fmt" + "net/http" + "strings" +) + +func HttpRequest(url, method, requestBody string) (*http.Response, error) { + // TLS 설정 + tr := &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // 인증서 검증 비활성화 + } + client := &http.Client{Transport: tr} + + // client := &http.Client{} + payload := strings.NewReader(requestBody) + req, _ := http.NewRequest(method, url, payload) + req.Header.Set("Content-Type", "application/json") + + // 요청 + res, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("요청 오류: %w", err) + } + + if res.StatusCode != http.StatusOK { + return nil, fmt.Errorf("error: received non-200 response status: %s", res.Status) + } + + return res, nil +} diff --git a/icslog/icslog.go b/icslog/icslog.go new file mode 100644 index 0000000..0309832 --- /dev/null +++ b/icslog/icslog.go @@ -0,0 +1,35 @@ +package icslog + +import ( + "log" + "mybatch/icsconf" + "os" + "path/filepath" + "time" +) + +var cfg icsconf.AppInfo + +func init() { + cfg = icsconf.Getconfig() +} + +func InitializeLogger() *log.Logger { + logDirectory := cfg.Directories.LOGDirectory + currentTime := time.Now().Format("20060102") // YYYY-MM-DD 형식 + logFileName := "icsbc.log-" + currentTime + + logFilePath := filepath.Join(logDirectory, logFileName) + + file, err := os.OpenFile(logFilePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) + if err != nil { + log.Fatal(err) + } + + logger := log.New(file, "", log.LstdFlags) + return logger +} + +func LogMessage(logger *log.Logger, message string) { + logger.Println(message) +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..5345cec --- /dev/null +++ b/main.go @@ -0,0 +1,15 @@ +package main + +import ( + mybatch "mybatch/icsbatch" + // stt "mybatch/icsstt" +) + +func main() { + // 매일 새벽 1시로 설정 + mybatch.BatchForPostRequestForDataListTest() + + // 배치 없이 http, ws, stt 바로 호출 + //stt.ProcessPostRequestForDataList() + +}