├── .dockerignore ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE ├── OCI.md ├── README.md ├── _config.yml ├── build_container.sh ├── cmd ├── constants.go └── nctalkproxyd │ └── main.go ├── examples └── nctalkproxyd.yaml ├── go.mod ├── go.sum ├── images ├── jitsi_meet_node_client.png ├── nctalkbot-framework.png └── nctalkbot-framework.svg ├── packaging └── arch │ └── PKGBUILD.git ├── pkg ├── clients │ ├── chat.go │ ├── nextcloud_talk.go │ └── room.go ├── protos │ ├── generated │ │ ├── index.pb.go │ │ └── nextcloud_talk.pb.go │ ├── index.proto │ └── nextcloud_talk.proto └── services │ └── nextcloud_talk.go └── usr └── lib └── systemd └── system └── nctalkproxyd.service /.dockerignore: -------------------------------------------------------------------------------- 1 | *.db -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.db 2 | PKGBUILD.* 3 | *.zstd -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at felicitas@pojtinger.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Compile binary 4 | 5 | On your build system you need an up to date go compiler. Create an executable like this 6 | 7 | ```bash 8 | $ go build -o /tmp/nctalkproxyd cmd/nctalkproxyd/main.go 9 | ``` 10 | 11 | ## Create an OCI image 12 | 13 | The source code does provide a bash-script to create an OCI format based image. 14 | OCI image do allow installation as rootless package 15 | 16 | ```bash 17 | $ bash -x ./build_container.sh 18 | ``` 19 | 20 | ## Uploading to Quay.io 21 | 22 | Get the container-id to be uploaded: 23 | 24 | ```bash 25 | $ imageid=$(buildah image | grep $botname | awk -F " " '{ print $3 }') 26 | ``` 27 | 28 | Tag the container to an image: 29 | 30 | ```bash 31 | $ buildah commit $imageid quay.io/username/$botname:latest 32 | ``` 33 | 34 | Now login to Quay.io: 35 | 36 | ```bash 37 | % podman login quay.io 38 | ``` 39 | 40 | Finally upload: 41 | 42 | ```bash 43 | $ buildah push quay.io/username/$botname:latest 44 | ``` 45 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:alpine AS build 2 | 3 | WORKDIR /app 4 | 5 | RUN apk add -u protobuf git 6 | RUN go get github.com/golang/protobuf/protoc-gen-go 7 | 8 | COPY . . 9 | 10 | RUN go build -o /tmp/nctalkproxyd ./cmd/nctalkproxyd/main.go 11 | 12 | FROM alpine 13 | 14 | COPY --from=build /tmp/nctalkproxyd /usr/local/bin 15 | 16 | CMD /usr/local/bin/nctalkproxyd 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /OCI.md: -------------------------------------------------------------------------------- 1 | # OCI 2 | 3 | An Open Containers Initiative (OCI) image that provides `nctalkproxyd` is available at 4 | [Quay.io](https://quay.io/rzerres/nctalkproxyd). 5 | 6 | The images can be combined with the bot image of `nctalk-bot-jitsi`. Its up to you, to 7 | choose an adequate pod mode. 8 | 9 | * umbrella pod: a single pod, where both images are legal citizens 10 | * multi pod: each image is executed its own pod instance (eg. to address scalability, cluster-awareness, etc) 11 | 12 | Please talk into account, that internetworking between pods is ony supported for images running in root mode 13 | (as of podman <= v1.8.2) 14 | 15 | ## Installation 16 | 17 | Pull the image: 18 | 19 | ```bash 20 | $ podman pull quay.io/rzerres/nctalkproxyd:latest 21 | ``` 22 | 23 | Check the network setup 24 | 25 | ```bash 26 | $ podman network ls 27 | ```bash 28 | 29 | if you need a new definition, go ahead and create one with your prefered driver (default: "bridge") 30 | 31 | ```bash 32 | $ podman network create --driver bridge nctalkproxyd 33 | ``` 34 | 35 | ## Systemd handling (multi pod) 36 | 37 | On a `systemd` capable distro, you OCI images can be managed combining a `systemd.service` with the `podman` 38 | binary. If you are not familiar with `podman` yet, you might simply put: `alias docker=podman`. Beside using 39 | it as a drop-in replacement for docker, there are a couple of advantages: 40 | 41 | - OCI compliant 42 | - rootless and root mode 43 | - daemonless 44 | - direct interaction with Container Registy, Containers, Image Storage and runc 45 | 46 | To create the systemd.service, run 47 | 48 | ```bash 49 | $ podman create --detach --name nctalkproxyd nctalkproxy:latest -u -p -r "https://your.nextcloud.url" 50 | $ podman generate systemd --name nctalkproxyd > /etc/systemd/system/nctalkproxyd.service 51 | ``` 52 | 53 | Have a look at [running containers with podman](https://www.redhat.com/sysadmin/podman-shareable-systemd-services) 54 | to get more insightdetails. 55 | 56 | ## Adaptation 57 | 58 | #The required parameters for `nctalkproxyd` can be adapted either via a config file, via config 59 | parameters or via corresponding environment variables. The latter take precedence. 60 | 61 | ```bash 62 | $ systemctl edit --full nctalkproxyd.service 63 | ``` 64 | 65 | The config file is preset with the following defaults: 66 | 67 | ```bash 68 | $ cat /etc/nctalkproxyd.yaml 69 | 70 | nctalkproxyd: 71 | addrLocale: :1969 72 | addrRemote: https://mynextcloud.com 73 | username: botusername 74 | password: botpassword 75 | dbpath: /var/lib/nctalkproxyd 76 | ``` 77 | 78 | Adapt the environment variables with appropriate values. 79 | 80 | ```env 81 | NCTALKPROXYD_DBPATH=/var/lib/nctalkproxyd 82 | NCTALKPROXYD_USERNAME=botusername 83 | NCTALKPROXYD_PASSWORD=botpassword 84 | NCTALKPROXYD_ADDRLOCAL=:1969 85 | NCTALKPROXYD_ADDRREMOTE=https://mynextcloud.com 86 | ``` 87 | 88 | Finally start the service. 89 | 90 | ```bash 91 | $ systemctl enable nctalkproxy.service 92 | $ systemctl start nctalkproxy.service 93 | ``` 94 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Nextcloud Talk Bot Framework 2 | 3 | A framework to realize Nextcloud Talk chatbots in a client/server model, where sessions exchange data via gRPC stubs. 4 | 5 | The bot has bin re-written as `nctalkbot-jitsi`. It takes advantage of the new framework and implements the client side. 6 | Please have a look at at [pojntfx/nextcloud-talk-bot-jitsi](https://github.com/pojntfx/nextcloud-talk-bot-jitsi). 7 | The server part is available as `nctalkproxyd`. The source-code is provided in this repo. 8 | 9 | Take a look at the following introduction video: 10 | 11 | [![thumbnail](https://i3.ytimg.com/vi/WRYlHDGApZo/maxresdefault.jpg)](https://www.youtube.com/watch?v=WRYlHDGApZo) 12 | 13 | ## Overview 14 | 15 | The Nextcloud Talk Bot Framework discribes a client/server infrastructure to realize Nextcloud chatbots, 16 | that interact via gRPC sessions. Shown here is an example for [`nctalkbot-jitsi`](https://github.com/pojntfx/nextcloud-talk-bot-jitsi). 17 | 18 | - **Server side**: 19 | `nctalkproxyd` implements a server instance written in the **Go** language. This component 20 | handles all the interaction with the Nextcloud API. It will listen for new chat requests while 21 | monitoring the associated rooms. Chat requests will be processed and the relavant data are proxied 22 | via gRPC messages to the client side. The new session will be advertised inside the addressed Nextcloud chat. 23 | 24 | - **Client side**: 25 | In order to create a chatbot, a client counterpart has to be implemented in any gRPC supported language. 26 | This Client will interacts with `nctalkproxyd` sending and recieving messages. The latter will will take care 27 | of all the heavy lifting (eg. handling the Nextcloud Talk API, keeping track of participants). 28 | `nctalkbot-jitsi` is a reference implementation written in **JavaScript**. 29 | 30 | - **Jitsi-Meet**: 31 | Participants will connect to the initiated Jitsi meeting inside a new window of their browser session. 32 | `jitsi-meet-node` will take care to process the needed steps. The communication with the Jitsi-Meet server 33 | follows the [JitsiMeetExternal API](ttps://github.com/jitsi/jitsi-meet/blob/master/doc/api.md). 34 | The framework is taking care to preset the Session parameters (eg. Name, password), beside participant 35 | specicfic options (participant name, language, etc). 36 | 37 | The following image try to illustrate the major components and its workflow. 38 | 39 | ![nctalkbot-framework.png](./images/nctalkbot-framework.png) 40 | 41 | ## Installation 42 | 43 | ### Go Package 44 | 45 | A Go package [is available](https://pkg.go.dev/mod/github.com/pojntfx/nextcloud-talk-bot-framework). 46 | 47 | ### Docker Image 48 | 49 | A Docker image is available at [Docker Hub](https://hub.docker.com/r/pojntfx/nctalkproxyd). 50 | 51 | ### Others 52 | 53 | If you're interested in using alternatives like OCI images, see [OCI](./OCI.md). 54 | 55 | ## Usage 56 | 57 | The API will asure fast and secure messsage exchange via gRPC using protocol buffers. The protocol description 58 | itself is defined in [pkg/protos/nextcloud_talk.proto](./pkg/protos/nextcloud_talk.proto). 59 | 60 | [`nctalkbot-jitsi`](https://github.com/pojntfx/nextcloud-talk-bot-jitsi) is a pretty advanced chatbot implementation, 61 | using this framework. Take it as a reference. 62 | 63 | `nctalkproxyd` will integrate itself in the Nextcloud Talk infrastructure while authenticating as a dedicated user. 64 | In order to use the bot, this user (e.g. name it "jitsibot") needs to be added as a participent in every Nextcloud Talk room. 65 | You will handle that as an admin user from within the Nextcloud GUI. 66 | 67 | The following code will interconnect a `nctalkproxyd` docker container with a `nctalkbot-jitsi`container. 68 | Please adapt variables to meet your production/testing needs. The given values are just examples: 69 | 70 | ```bash 71 | % docker volume create nctalkproxyd 72 | % docker network create nctalkbots 73 | % docker run \ 74 | -p 1969:1969 \ 75 | -v nctalkproxyd:/var/lib/nctalkproxyd \ 76 | -e NCTALKPROXYD_DBPATH=/var/lib/nctalkproxyd \ 77 | -e NCTALKPROXYD_USERNAME=botusername \ 78 | -e NCTALKPROXYD_PASSWORD=botpassword \ 79 | -e NCTALKPROXYD_ADDRREMOTE=https://mynextcloud.com \ 80 | --network nctalkchatbots \ 81 | --name nctalkproxyd \ 82 | -d pojntfx/nctalkproxyd 83 | % docker run \ 84 | -e NCTALKBOT_BOT_NAME=botusername \ 85 | -e NCTALKBOT_COMMANDS=\#videochat,\#videocall,\#custom \ 86 | -e NCTALKBOT_SLEEP_TIME=20 \ 87 | -e NCTALKBOT_JITSI_ADDR=meet.jit.si \ 88 | -e NCTALKBOT_JITSI_ROOM_PASSWORD_BYTE_LENGTH=1 \ 89 | -e NCTALKBOT_NCTALKPROXYD_ADDR=localhost:1969 \ 90 | --network nctalkbots \ 91 | -d pojntfx/nctalkbot-jitsi 92 | ``` 93 | 94 | ## License 95 | 96 | Nextcloud Talk Bot Framework (c) 2020 Felicitas Pojtinger 97 | 98 | SPDX-License-Identifier: AGPL-3.0 99 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /build_container.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -x 4 | 5 | ### 6 | # buildah: creating a container for Nextcloud-Talk proxy daemon (OCI format) 7 | ### 8 | 9 | push_image=1 10 | mount_image=1 11 | 12 | # variables 13 | author='Felicitas Pojtinger @pojntfx' 14 | maintainer='Ralf Zerres @rzerres' 15 | botname=nctalkproxyd 16 | buildroot=/run/buildah 17 | prefix=/usr/local 18 | 19 | # signing with GPG Package-Key 20 | signkey=1EC4BE4FF2A6C9F4DDDF30F33C5F485DBD250D66 21 | 22 | # authenticate at quay.io with robot account (env: REGISTRY_AUTH_FILE) 23 | repo=quay.io 24 | username=rzerres 25 | authfile=$HOME/.docker/config.json 26 | 27 | # create a container -> docker image golang (flavor: alpine) 28 | mycontainer=$(buildah from --name $botname golang:alpine) 29 | 30 | # adapt containers metadata 31 | buildah config --author="$author" $mycontainer 32 | buildah config --label name=$botname $mycontainer 33 | buildah config --label maintainer="$maintainer" $mycontainer 34 | buildah config --env NCTALKPROXYD_USERNAME="jitsibot" $mycontainer 35 | buildah config --env NCTALKPROXYD_PASSWORD="password" $mycontainer 36 | buildah config --env NCTALKPROXYD_DBLOCATION="/run/$botname" $mycontainer 37 | buildah config --env NCTALKPROXYD_ADDRLOCAL="https://localhost:1696" $mycontainer 38 | buildah config --env NCTALKPROXYD_ADDRREMOTE="https://my.nextcloud.local" $mycontainer 39 | 40 | # create the build environment inside the container 41 | #buildah config --env GOPATH="$buildroot" $mycontainer 42 | buildah config --entrypoint "[ \"/usr/local/bin/$botname\" ]" $mycontainer 43 | buildah config --workingdir="$buildroot" $mycontainer 44 | 45 | # get dependencies 46 | buildah run $mycontainer apk add --no-cache --virtual .build-deps protobuf git 47 | buildah run $mycontainer go get github.com/golang/protobuf/protoc-gen-go 48 | buildah copy $mycontainer . 49 | 50 | # create the binary 51 | buildah run $mycontainer go build -o $buildroot/$botname ./cmd/$botname/main.go 52 | 53 | # prepare the destination container 54 | buildah run $mycontainer mkdir -p $prefix/etc 55 | buildah run $mycontainer cp $buildroot/$botname $prefix/bin/$botname 56 | buildah run $mycontainer cp $buildroot/examples/$botname.yaml $prefix/etc/$botname.yaml 57 | buildah run $mycontainer ln -s $prefix/etc/$botname.yaml /etc/$botname.yaml 58 | buildah run $mycontainer mkdir /run/$botname 59 | 60 | # allow manual adaptions 61 | if [ "$mount_image" -eq 1 ]; then 62 | read -p "Mount the created container for interactive adaptions (y/n)? " -t 15 doMount 63 | # for rootless mode: run in user namespace 64 | if [ "$doMount" = "y" ]; then 65 | echo "You are inside the container tree. Build environment hasn't been flushed yet!" 66 | if [ $(id -u) -eq 0 ]; then 67 | # execution in root mode 68 | mountpoint=$(buildah mount $mycontainer) 69 | cd $mountpoint 70 | du -sh * 71 | sh 72 | buildah umount $mycontainer 73 | else 74 | # execution in rootless mode 75 | # not starting with usernamespace, default to isolate the filesystem with chroot 76 | #ENV _BUILDAH_STARTED_IN_USERNS="" BUILDAH_ISOLATION=chroot 77 | buildah unshare --mount containerID du -sh ${containerID}/* 78 | #buildah unshare du -sh $mountpoint/* 79 | buildah unshare sh 80 | #buildah unshare umount $mountpoint 81 | fi 82 | fi 83 | fi 84 | 85 | # cleanup dependencies 86 | buildah run $mycontainer apk del .build-deps 87 | 88 | # cleanup build environment 89 | buildah config --workingdir="/" $mycontainer 90 | buildah run $mycontainer rm -rf $buildroot 91 | buildah run $mycontainer rm -rf go 92 | buildah run $mycontainer rm -rf usr/local/go usr/local/lib usr/local/share root/.cache 93 | 94 | # tag the container to an image name, sign it. on success remove container 95 | imageid=$(buildah commit \ 96 | --rm \ 97 | --squash \ 98 | $mycontainer $repo/$username/$botname) 99 | #--sign-by $signkey \ 100 | 101 | # tag our new image with an alternate name 102 | #buildah tag $botname nctjb 103 | 104 | if [ "$push_image" -eq 1 ]; then 105 | # push image to Quay Container Registry 106 | #imageid=$(buildah images | grep $repo/$username/$botname | awk -F ' ' '{print $3}') 107 | buildah push \ 108 | --authfile $authfile \ 109 | $imageid docker://$repo/$username/$botname 110 | fi 111 | -------------------------------------------------------------------------------- /cmd/constants.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | const ( 4 | NcTalkProxydDefaultAddrLocal = ":1969" // NcTalkProxydDefaultAddrLocal is the default Host:port of `nctalkproxyd`. 5 | NcTalkProxyConfigurationFile = "Basename of configuration file." // NcTalkProxydConfigurationFile is the name of the configuration file. 6 | ) 7 | 8 | const ( 9 | CouldNotBindFlagsErrorMessage = "could not bind flags" // CouldNotBindFlagsErrorMessage is the error message to throw if binding the flags has failed. 10 | CouldNotStartRootCommandErrorMessage = "could not start root command" // CouldNotStartRootCommandErrorMessage is the error message to throw if starting the root command has failed. 11 | ) 12 | -------------------------------------------------------------------------------- /cmd/nctalkproxyd/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "strings" 7 | 8 | "github.com/pojntfx/nextcloud-talk-bot-framework/cmd" 9 | "github.com/pojntfx/nextcloud-talk-bot-framework/pkg/clients" 10 | nextcloudTalk "github.com/pojntfx/nextcloud-talk-bot-framework/pkg/protos/generated" 11 | "github.com/pojntfx/nextcloud-talk-bot-framework/pkg/services" 12 | "github.com/spf13/cobra" 13 | "github.com/spf13/viper" 14 | "gitlab.com/bloom42/libs/rz-go" 15 | "gitlab.com/bloom42/libs/rz-go/log" 16 | "google.golang.org/grpc" 17 | "google.golang.org/grpc/reflection" 18 | ) 19 | 20 | const ( 21 | keyPrefix = "nctalkproxyd." 22 | configFileDefault = "nctalkproxyd" // viper will resolve supported format extension 23 | configFileKey = keyPrefix + "configFile" 24 | addrLocalKey = keyPrefix + "addrLocal" 25 | addrRemoteKey = keyPrefix + "addrRemote" 26 | usernameKey = keyPrefix + "username" 27 | passwordKey = keyPrefix + "password" 28 | dbpathKey = keyPrefix + "dbpath" 29 | ) 30 | 31 | var ( 32 | // commandline flags 33 | configFile string 34 | addrLocalFlag string 35 | addrRemoteFlag string 36 | usernameFlag string 37 | passwordFlag string 38 | dbpathFlag string 39 | 40 | rootCmd = &cobra.Command{ 41 | Use: "nctalkproxyd", 42 | Short: "nctalkproxyd is a Nextcloud Talk API gRPC proxy daemon.", 43 | Long: `nctalkproxyd is a Nextcloud Talk API gRPC proxy daemon. 44 | 45 | Find more information at: 46 | https://pojntfx.github.io/nextcloud-talk-bot-framework/`, 47 | Version: "0.2", 48 | PersistentPreRun: func(cmd *cobra.Command, args []string) { 49 | // convert Environment parameter names with camel case syntax 50 | viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_", ".", "_")) 51 | }, 52 | 53 | // our main function, running the proxy routines 54 | RunE: func(cmd *cobra.Command, args []string) error { 55 | listener, err := net.Listen("tcp", viper.GetString(addrLocalKey)) 56 | if err != nil { 57 | return err 58 | } else { 59 | log.Info("nctalkproxyd: listener established", rz.String("addrLocal", viper.GetString(addrLocalKey))) 60 | } 61 | 62 | server := grpc.NewServer() 63 | reflection.Register(server) 64 | 65 | chatChan := make(chan clients.Chat) 66 | chatRequestChan := make(chan bool) 67 | chatChans := []chan clients.Chat{} 68 | chatResponseChan := make(chan chan clients.Chat) 69 | statusChan, svcStatusChan := make(chan string), make(chan string) 70 | 71 | nextcloudTalkClient := clients.NewNextcloudTalk( 72 | viper.GetString(addrRemoteKey), 73 | viper.GetString(usernameKey), 74 | viper.GetString(passwordKey), 75 | viper.GetString(dbpathKey), 76 | chatChan, 77 | statusChan, 78 | ) 79 | log.Info("nctalkproxyd: Bot connection to NextcloudTalk configured", 80 | rz.String("addrRemote", viper.GetString(addrRemoteKey)), 81 | rz.String("user", viper.GetString(usernameKey))) 82 | 83 | writeChan := func(token, message string) error { 84 | log.Info("writing chat from client to Nextcloud Talk", 85 | rz.String("token", token), rz.String("message", message)) 86 | 87 | return nextcloudTalkClient.WriteChat(token, message) 88 | } 89 | 90 | defer nextcloudTalkClient.Close() 91 | if err := nextcloudTalkClient.Open(); err != nil { 92 | log.Fatal("could not open Nextcloud Talk client", rz.Err(err)) 93 | } 94 | 95 | go func() { 96 | for { 97 | if err := nextcloudTalkClient.ReadRooms(); err != nil { 98 | log.Info("could not read rooms, retrying", rz.Err(err)) 99 | } 100 | } 101 | }() 102 | 103 | go func() { 104 | for { 105 | if err := nextcloudTalkClient.ReadChats(); err != nil { 106 | log.Info("could not read chats, retrying", rz.Err(err)) 107 | } 108 | } 109 | }() 110 | 111 | go func() { 112 | for status := range statusChan { 113 | log.Info("received Nextcloud client status", rz.String("status", status)) 114 | } 115 | }() 116 | 117 | go func() { 118 | for status := range svcStatusChan { 119 | log.Info("received service status", rz.String("status", status)) 120 | } 121 | }() 122 | 123 | go func() { 124 | for range chatRequestChan { 125 | log.Info("new client connected to service") 126 | 127 | chatChan := make(chan clients.Chat) 128 | 129 | chatChans = append(chatChans, chatChan) 130 | 131 | chatResponseChan <- chatChan 132 | } 133 | }() 134 | 135 | go func() { 136 | for chat := range chatChan { 137 | log.Info("writing chat from Nextcloud Talk to clients", rz.Any("chat", chat)) 138 | 139 | for _, chatChan := range chatChans { 140 | chatChan <- chat 141 | } 142 | } 143 | }() 144 | 145 | nextcloudTalkService := services.NewNextcloudTalk(chatRequestChan, chatResponseChan, svcStatusChan, writeChan) 146 | 147 | nextcloudTalk.RegisterNextcloudTalkServer(server, nextcloudTalkService) 148 | 149 | log.Info("starting server") 150 | 151 | return server.Serve(listener) 152 | }, 153 | } 154 | ) 155 | 156 | var versionCmd = &cobra.Command{ 157 | Use: "version", 158 | Short: "nctalkproxyd is a Nextcloud Talk API gRPC proxy daemon.", 159 | Long: `nctalkproxyd is implementet in the go language`, 160 | } 161 | 162 | func init() { 163 | cobra.OnInitialize(initConfig) 164 | 165 | rootCmd.PersistentFlags().StringVarP(&configFile, configFileKey, "c", configFileDefault, cmd.NcTalkProxyConfigurationFile) 166 | rootCmd.PersistentFlags().StringVarP(&addrLocalFlag, addrLocalKey, "l", cmd.NcTalkProxydDefaultAddrLocal, "NcTalkProxyd socket.") 167 | rootCmd.PersistentFlags().StringVarP(&addrRemoteFlag, addrRemoteKey, "r", "https://mynetxcloud.com", "Nextcloud bot URL.") 168 | rootCmd.PersistentFlags().StringVarP(&usernameFlag, usernameKey, "u", "botusername", "Nextcloud bot account username.") 169 | rootCmd.PersistentFlags().StringVarP(&passwordFlag, passwordKey, "p", "botpassword", "Nextcloud bot account password.") 170 | rootCmd.PersistentFlags().StringVarP(&dbpathFlag, dbpathKey, "d", "/var/lib/nctalkproxyd", "Database path.") 171 | rootCmd.PersistentFlags().Bool("viper", true, "use Viper for configuration") 172 | 173 | viper.BindPFlag("author", rootCmd.PersistentFlags().Lookup("author")) 174 | viper.BindPFlag("useViper", rootCmd.PersistentFlags().Lookup("viper")) 175 | viper.SetDefault("author", "Felicitas Pojntinger") 176 | viper.SetDefault("license", "AGPLv3") 177 | 178 | if err := viper.BindPFlags(rootCmd.PersistentFlags()); err != nil { 179 | log.Fatal(cmd.CouldNotBindFlagsErrorMessage, rz.Err(err)) 180 | } 181 | 182 | rootCmd.AddCommand(versionCmd) 183 | } 184 | 185 | func initConfig() { 186 | // Search given config file in standard directoies 187 | viper.AddConfigPath("/etc/") 188 | viper.AddConfigPath("/etc/nctalkproxyd/") 189 | viper.AddConfigPath(".") 190 | 191 | // handle config file 192 | if len(viper.GetString(configFileKey)) > 0 { 193 | // Use config file from the flag. 194 | fmt.Println("Using config file:", configFile) 195 | viper.SetConfigName(configFile) 196 | 197 | // Searches for config file in given paths and read it 198 | if err := viper.ReadInConfig(); err != nil { 199 | if _, ok := err.(viper.ConfigFileNotFoundError); ok { 200 | if !(viper.GetString(configFileKey) == configFileDefault) { 201 | log.Fatal("Failed to read given configuration file!", rz.Err(err)) 202 | } else { 203 | log.Info("nctalkproxyd: default config file not found", rz.Err(err)) 204 | log.Info("nctalkproxyd: using build-in defaults") 205 | } 206 | } else { 207 | // Config file was found but another error was produced 208 | log.Info("nctalkproxyd: error reading config file", rz.String("configFile", viper.GetString(configFile))) 209 | } 210 | } 211 | } else { 212 | log.Info("nctalkproxyd: no config file selected, using buildin flags ...") 213 | } 214 | 215 | // handle environment variables: if set, they take precedence 216 | viper.AutomaticEnv() 217 | 218 | // array with valid environment variables 219 | env_vars := []string{ 220 | "nctalkproxyd_addrRemote", 221 | "nctalkproxyd_addrLocal", 222 | "nctalkproxyd_username", 223 | "nctalkproxyd_password", 224 | "nctalkproxyd_dbpath", 225 | } 226 | 227 | for i := 0; i < len(env_vars); i++ { 228 | if viper.Get(env_vars[i]) != nil { 229 | if env_vars[i] != "nctalkproxyd_password" { 230 | log.Debug("nctalkproxyd: environment value", rz.String(env_vars[i], viper.GetString(env_vars[i]))) 231 | } else { 232 | log.Debug("nctalkproxyd: environment value", rz.String(env_vars[i], "*******")) 233 | } 234 | } 235 | } 236 | } 237 | 238 | func main() { 239 | if err := rootCmd.Execute(); err != nil { 240 | log.Fatal(cmd.CouldNotStartRootCommandErrorMessage, rz.Err(err)) 241 | } 242 | } 243 | -------------------------------------------------------------------------------- /examples/nctalkproxyd.yaml: -------------------------------------------------------------------------------- 1 | nctalkproxyd: 2 | addrLocale: :1969 3 | addrRemote: https://examplenextcloud.com 4 | username: botusername 5 | password: botpassword 6 | dbpath: /var/lib/nctalkproxyd 7 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/pojntfx/nextcloud-talk-bot-framework 2 | 3 | go 1.14 4 | 5 | require ( 6 | github.com/akrylysov/pogreb v0.9.1 7 | github.com/go-resty/resty/v2 v2.2.0 8 | github.com/golang/protobuf v1.3.5 9 | github.com/spf13/cobra v0.0.7 10 | github.com/spf13/viper v1.6.3 11 | gitlab.com/bloom42/libs/rz-go v1.3.0 12 | google.golang.org/grpc v1.28.1 13 | ) 14 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 3 | github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= 4 | github.com/akrylysov/pogreb v0.9.1 h1:kO4TD2qaiCD0TtIjEj3ta1rCTMtyp61RxuD4cet7S14= 5 | github.com/akrylysov/pogreb v0.9.1/go.mod h1:pNs6QmpQ1UlTJKDezuRWmaqkgUE2TuU0YTWyqJZ7+lI= 6 | github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= 7 | github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 8 | github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= 9 | github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 10 | github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= 11 | github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= 12 | github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= 13 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 14 | github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= 15 | github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= 16 | github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= 17 | github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= 18 | github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= 19 | github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= 20 | github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= 21 | github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= 22 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 23 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 24 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 25 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= 26 | github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= 27 | github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 28 | github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= 29 | github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= 30 | github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= 31 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 32 | github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 33 | github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= 34 | github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= 35 | github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= 36 | github.com/go-resty/resty v1.12.0 h1:L1P5qymrXL5H/doXe2pKUr1wxovAI5ilm2LdVLbwThc= 37 | github.com/go-resty/resty/v2 v2.2.0 h1:vgZ1cdblp8Aw4jZj3ZsKh6yKAlMg3CHMrqFSFFd+jgY= 38 | github.com/go-resty/resty/v2 v2.2.0/go.mod h1:nYW/8rxqQCmI3bPz9Fsmjbr2FBjGuR2Mzt6kDh3zZ7w= 39 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= 40 | github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 41 | github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= 42 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 43 | github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 44 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 45 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 46 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 47 | github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 48 | github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= 49 | github.com/golang/protobuf v1.3.5 h1:F768QJ1E9tib+q5Sc8MkdJi1RxLTbRcTf8LJV56aRls= 50 | github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= 51 | github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 52 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 53 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 54 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= 55 | github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= 56 | github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= 57 | github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= 58 | github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= 59 | github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= 60 | github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= 61 | github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= 62 | github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= 63 | github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= 64 | github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= 65 | github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= 66 | github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= 67 | github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= 68 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 69 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 70 | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= 71 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 72 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 73 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 74 | github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= 75 | github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= 76 | github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= 77 | github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= 78 | github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 79 | github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= 80 | github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 81 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 82 | github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 83 | github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 84 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= 85 | github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= 86 | github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= 87 | github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= 88 | github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 89 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 90 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 91 | github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= 92 | github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= 93 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 94 | github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 95 | github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 96 | github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= 97 | github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 98 | github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 99 | github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= 100 | github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= 101 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= 102 | github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 103 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= 104 | github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= 105 | github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= 106 | github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= 107 | github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= 108 | github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= 109 | github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= 110 | github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= 111 | github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= 112 | github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= 113 | github.com/spf13/cobra v0.0.7 h1:FfTH+vuMXOas8jmfb5/M7dzEYx7LpcLb7a0LPe34uOU= 114 | github.com/spf13/cobra v0.0.7/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= 115 | github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= 116 | github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= 117 | github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= 118 | github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 119 | github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= 120 | github.com/spf13/viper v1.6.3 h1:pDDu1OyEDTKzpJwdq4TiuLyMsUgRa/BT5cn5O62NoHs= 121 | github.com/spf13/viper v1.6.3/go.mod h1:jUMtyi0/lB5yZH/FjyGAoH7IMNrIhlBf6pXZmbMDvzw= 122 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 123 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 124 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 125 | github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= 126 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 127 | github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= 128 | github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= 129 | github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= 130 | github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= 131 | github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= 132 | github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= 133 | gitlab.com/bloom42/libs/rz-go v1.3.0 h1:ex51jAhN1/tecDMAmyTrmDcjQxb2NKiVFnHpJSCw/GY= 134 | gitlab.com/bloom42/libs/rz-go v1.3.0/go.mod h1:/G8JCs/z9FPn+XYJT9e52gj76clf4dk8tf2jbq1HCpQ= 135 | go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= 136 | go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= 137 | go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= 138 | go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= 139 | golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 140 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 141 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 142 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 143 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= 144 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 145 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 146 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 147 | golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 148 | golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 149 | golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 150 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 151 | golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= 152 | golang.org/x/net v0.0.0-20200222125558-5a598a2470a0 h1:MsuvTghUPjX762sGLnGsxC3HM0B5r83wEtYcYR8/vRs= 153 | golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 154 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 155 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 156 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 157 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 158 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 159 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 160 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 161 | golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 162 | golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 163 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= 164 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 165 | golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= 166 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 167 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 168 | golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 169 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 170 | golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= 171 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 172 | golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 173 | golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 174 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 175 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 176 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 177 | google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= 178 | google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= 179 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 180 | google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= 181 | google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= 182 | google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= 183 | google.golang.org/grpc v1.28.1 h1:C1QC6KzgSiLyBabDi87BbjaGreoRgGUF5nOyvfrAZ1k= 184 | google.golang.org/grpc v1.28.1/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= 185 | gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 186 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 187 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 188 | gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= 189 | gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= 190 | gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= 191 | gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= 192 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 193 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 194 | gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= 195 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 196 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 197 | honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 198 | -------------------------------------------------------------------------------- /images/jitsi_meet_node_client.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pojntfx/nextcloud-talk-bot-framework/cc1490b4ffe9b39ed74f2f9c39feec347478ce1d/images/jitsi_meet_node_client.png -------------------------------------------------------------------------------- /images/nctalkbot-framework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pojntfx/nextcloud-talk-bot-framework/cc1490b4ffe9b39ed74f2f9c39feec347478ce1d/images/nctalkbot-framework.png -------------------------------------------------------------------------------- /packaging/arch/PKGBUILD.git: -------------------------------------------------------------------------------- 1 | # vim:set ts=8 sw=8 et: 2 | # Maintainer: Ralf Zerres 3 | 4 | pkgname=nctalkproxyd-git 5 | _pkgname=nctalkproxyd 6 | _branch=master 7 | pkgver=0.r82.g8f9ae82 8 | pkgrel=1 9 | pkgdesc="A Nextcloud Talk API gRPC proxy daemon" 10 | url="https://github.com/pojntfx/nextcloud-talk-bot-framework" 11 | depends=('go') 12 | makedepends=('go') 13 | backup=("etc/nctalkproxyd.yaml") 14 | arch=('x86_64') 15 | license=('GPL') 16 | source=("${pkgname}::git+https://github.com/pojntfx/nextcloud-talk-bot-framework.git#branch=${_branch}") 17 | #install=_$pkgname.install 18 | provides=("$_pkgname") 19 | #conflicts=('$_pkgname') 20 | sha256sums=('SKIP') 21 | validpgpkeys=( 22 | '1EC4BE4FF2A6C9F4DDDF30F33C5F485DBD250D66' # Ralf Zerres (Package Signing) 23 | ) 24 | 25 | prepare() { 26 | cd "$srcdir"/${pkgbase} 27 | 28 | # check out given branch and update to head 29 | git checkout $_branch 30 | echo "prepare: pull $_branch" 31 | git pull --rebase 32 | 33 | # patching 34 | if [ ! -f .makepkg-patched ]; then 35 | msg2 "patching:" 36 | #git am --signoff ../../patches-git/0001-packaging-Arch-Linux-update-PKGBUILD.git.patch 37 | touch .makepkg-patched 38 | msg2 "no patches for branch '${_branch}' needed" 39 | 40 | cp -ax ../../usr . 41 | cp -ax ../../packaging . 42 | fi 43 | } 44 | 45 | pkgver() { 46 | pkgdir=("$srcdir/archpkg") 47 | echo "0.r$(git rev-list --count $_branch).g$(git log -1 --format="%h")" 48 | } 49 | 50 | build() { 51 | cd "$srcdir"/${pkgname} 52 | 53 | # create binary targets 54 | go build -o $_pkgname cmd/${_pkgname}/main.go 55 | } 56 | 57 | package() { 58 | cd "$srcdir"/${pkgname} 59 | 60 | install -D --mode 0750 "./${_pkgname}" "$pkgdir"/usr/bin/$_pkgname 61 | install -D --mode 0644 "./usr/lib/systemd/system/${_pkgname}.service" "$pkgdir"/usr/lib/systemd/system/${_pkgname}.service 62 | install -D --mode 0644 "./examples/${_pkgname}.yaml" "$pkgdir"/etc/${_pkgname}.yaml 63 | } 64 | -------------------------------------------------------------------------------- /pkg/clients/chat.go: -------------------------------------------------------------------------------- 1 | package clients 2 | 3 | // Chat is a chat message. 4 | type Chat struct { 5 | ID int `json:"id"` 6 | Token string `json:"token"` 7 | ActorType string `json:"actorType"` // guest, user 8 | ActorID string `json:"actorId"` 9 | ActorDisplayName string `json:"actorDisplayName"` 10 | IsReplyable bool `json:"isReplyable"` 11 | Message string `json:"message"` 12 | MessageParameters string `json:"messageParamertes"` //RichObjectString 13 | } 14 | 15 | // ChatResponse is the API response for chats. 16 | type ChatResponse struct { 17 | OCS struct { 18 | Data []Chat `json:"data"` 19 | } `json:"ocs"` 20 | } 21 | -------------------------------------------------------------------------------- /pkg/clients/nextcloud_talk.go: -------------------------------------------------------------------------------- 1 | package clients 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "path" 7 | "strconv" 8 | "time" 9 | 10 | "github.com/akrylysov/pogreb" 11 | "github.com/go-resty/resty/v2" 12 | ) 13 | 14 | // NextcloudTalk is a Nextcloud Talk client. 15 | type NextcloudTalk struct { 16 | url, username, password, dbLocation string 17 | chatChan chan Chat 18 | roomChan chan Room 19 | statusChan chan string 20 | knownIDs *pogreb.DB 21 | processedRooms []Room 22 | } 23 | 24 | // NewNextcloudTalk creates a new Nextcloud Talk Client. 25 | func NewNextcloudTalk(url, username, password, dbLocation string, chatChan chan Chat, statusChan chan string) *NextcloudTalk { 26 | return &NextcloudTalk{ 27 | url, username, password, dbLocation, chatChan, make(chan Room), statusChan, nil, []Room{}, 28 | } 29 | } 30 | 31 | // Open opens the client. 32 | func (n *NextcloudTalk) Open() error { 33 | knownIDs, err := pogreb.Open(n.dbLocation, nil) 34 | if err != nil { 35 | return err 36 | } 37 | n.knownIDs = knownIDs 38 | 39 | return nil 40 | } 41 | 42 | // Close closes the client. 43 | func (n *NextcloudTalk) Close() error { 44 | return n.knownIDs.Close() 45 | } 46 | 47 | // getRooms responses structure with available rooms 48 | func (n *NextcloudTalk) getRooms() ([]Room, error) { 49 | client := resty.New() 50 | 51 | res, err := client.R(). 52 | SetHeaders(map[string]string{ 53 | "OCS-APIRequest": "true", 54 | "Accept": "application/json", 55 | }). 56 | SetBasicAuth(n.username, n.password). 57 | Get(n.url + "/" + path.Join("ocs", "v2.php", "apps", "spreed", "api", "v1", "room")) 58 | if err != nil { 59 | return nil, err 60 | } 61 | 62 | var resStruct RoomResponse 63 | if err := json.Unmarshal(res.Body(), &resStruct); err != nil { 64 | if err != nil { 65 | return nil, err 66 | } 67 | } 68 | 69 | return resStruct.OCS.Data, nil 70 | } 71 | 72 | // getChats responses array with available chats 73 | func (n *NextcloudTalk) getChats(room string) ([]Chat, error) { 74 | client := resty.New() 75 | 76 | res, err := client.R(). 77 | SetHeaders(map[string]string{ 78 | "OCS-APIRequest": "true", 79 | "Accept": "application/json", 80 | }). 81 | SetQueryParams(map[string]string{ 82 | "setReadMarker": "true", 83 | "lookIntoFuture": "0", 84 | }). 85 | SetBasicAuth(n.username, n.password). 86 | Get(n.url + "/" + path.Join("ocs", "v2.php", "apps", "spreed", "api", "v1", "chat", room)) 87 | if err != nil { 88 | return nil, err 89 | } 90 | 91 | var resStruct ChatResponse 92 | if err := json.Unmarshal(res.Body(), &resStruct); err != nil { 93 | if err != nil { 94 | return nil, err 95 | } 96 | } 97 | 98 | return resStruct.OCS.Data, nil 99 | } 100 | 101 | // ReadChats reads the chats. 102 | func (n *NextcloudTalk) ReadChats() error { 103 | for room := range n.roomChan { 104 | n.statusChan <- fmt.Sprintf(`joined room "%v" ("%v") with ID "%v" and token "%v"`, room.DisplayName, room.Name, room.ID, room.Token) 105 | 106 | go func(currentRoom Room) { 107 | for { 108 | lastID := []byte{} 109 | has, err := n.knownIDs.Has([]byte(currentRoom.Token)) 110 | if err != nil { 111 | n.statusChan <- err.Error() 112 | } 113 | if has { 114 | lastID, err = n.knownIDs.Get([]byte(currentRoom.Token)) 115 | if err != nil { 116 | n.statusChan <- err.Error() 117 | 118 | continue 119 | } 120 | } 121 | 122 | chats, err := n.getChats(currentRoom.Token) 123 | if err != nil { 124 | if err.Error() == "invalid character '<' looking for beginning of value" { 125 | n.statusChan <- fmt.Sprintf(`left room "%v" ("%v") with ID "%v" and token "%v"`, currentRoom.DisplayName, currentRoom.Name, currentRoom.ID, currentRoom.Token) 126 | 127 | return 128 | } 129 | 130 | n.statusChan <- err.Error() 131 | 132 | // This means that the JSON output is invalid; this can happen during, for example, very high load situations. 133 | // Reconnect to the room in the next cycle 134 | newRooms := []Room{} 135 | for _, room := range n.processedRooms { 136 | if room.ID != currentRoom.ID { 137 | newRooms = append(newRooms, room) 138 | } 139 | } 140 | n.processedRooms = newRooms 141 | 142 | return 143 | } 144 | 145 | if len(chats) != 0 { 146 | chat := chats[0] 147 | if strconv.Itoa(chat.ID) != string(lastID) { 148 | n.chatChan <- chats[0] 149 | 150 | if err := n.knownIDs.Put([]byte(currentRoom.Token), []byte(strconv.Itoa(chat.ID))); err != nil { 151 | n.statusChan <- err.Error() 152 | } 153 | } 154 | } 155 | 156 | time.Sleep(time.Second * 5) 157 | } 158 | }(room) 159 | } 160 | 161 | return nil 162 | } 163 | 164 | // ReadRooms reads the rooms. 165 | func (n *NextcloudTalk) ReadRooms() error { 166 | var lastRooms []Room 167 | 168 | for { 169 | rooms, err := n.getRooms() 170 | if err != nil { 171 | return err 172 | } 173 | 174 | for _, room := range rooms { 175 | exists := false 176 | 177 | for _, lastRoom := range lastRooms { 178 | if room.ID == lastRoom.ID { 179 | exists = true 180 | 181 | break 182 | } 183 | } 184 | 185 | if !exists { 186 | n.roomChan <- room 187 | } 188 | } 189 | 190 | lastRooms = rooms 191 | 192 | time.Sleep(time.Second * 5) 193 | } 194 | } 195 | 196 | // WriteChat writes a chat. 197 | func (n *NextcloudTalk) WriteChat(room string, message string) error { 198 | client := resty.New() 199 | 200 | _, err := client.R(). 201 | SetHeaders(map[string]string{ 202 | "OCS-APIRequest": "true", 203 | "Accept": "application/json", 204 | }). 205 | SetQueryParams(map[string]string{ 206 | "message": message, 207 | }). 208 | SetBasicAuth(n.username, n.password). 209 | Post(n.url + "/" + path.Join("ocs", "v2.php", "apps", "spreed", "api", "v1", "chat", room)) 210 | 211 | return err 212 | } 213 | -------------------------------------------------------------------------------- /pkg/clients/room.go: -------------------------------------------------------------------------------- 1 | package clients 2 | 3 | // Room is a chat room 4 | type Room struct { 5 | ID int `json:"id"` 6 | Token string `json:"token"` 7 | Name string `json:"name"` 8 | DisplayName string `json:"displayName"` 9 | } 10 | 11 | // RoomResponse is the API response for rooms 12 | type RoomResponse struct { 13 | OCS struct { 14 | Data []Room `json:"data"` 15 | } `json:"ocs"` 16 | } 17 | -------------------------------------------------------------------------------- /pkg/protos/generated/index.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // source: index.proto 3 | 4 | package nextcloudTalk 5 | 6 | import ( 7 | fmt "fmt" 8 | proto "github.com/golang/protobuf/proto" 9 | math "math" 10 | ) 11 | 12 | // Reference imports to suppress errors if they are not otherwise used. 13 | var _ = proto.Marshal 14 | var _ = fmt.Errorf 15 | var _ = math.Inf 16 | 17 | // This is a compile-time assertion to ensure that this generated file 18 | // is compatible with the proto package it is being compiled against. 19 | // A compilation error at this line likely means your copy of the 20 | // proto package needs to be updated. 21 | const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package 22 | 23 | func init() { 24 | proto.RegisterFile("index.proto", fileDescriptor_f750e0f7889345b5) 25 | } 26 | 27 | var fileDescriptor_f750e0f7889345b5 = []byte{ 28 | // 68 bytes of a gzipped FileDescriptorProto 29 | 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0xce, 0xcc, 0x4b, 0x49, 30 | 0xad, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xcd, 0x4b, 0xad, 0x28, 0x49, 0xce, 0xc9, 31 | 0x2f, 0x4d, 0x09, 0x49, 0xcc, 0xc9, 0x96, 0x12, 0x81, 0x73, 0xe3, 0x4b, 0x80, 0x7c, 0x88, 0xa2, 32 | 0x00, 0x86, 0x24, 0x36, 0x30, 0xc3, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x33, 0x4a, 0xbe, 0x6e, 33 | 0x3c, 0x00, 0x00, 0x00, 34 | } 35 | -------------------------------------------------------------------------------- /pkg/protos/generated/nextcloud_talk.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // source: nextcloud_talk.proto 3 | 4 | package nextcloudTalk 5 | 6 | import ( 7 | context "context" 8 | fmt "fmt" 9 | proto "github.com/golang/protobuf/proto" 10 | empty "github.com/golang/protobuf/ptypes/empty" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | math "math" 15 | ) 16 | 17 | // Reference imports to suppress errors if they are not otherwise used. 18 | var _ = proto.Marshal 19 | var _ = fmt.Errorf 20 | var _ = math.Inf 21 | 22 | // This is a compile-time assertion to ensure that this generated file 23 | // is compatible with the proto package it is being compiled against. 24 | // A compilation error at this line likely means your copy of the 25 | // proto package needs to be updated. 26 | const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package 27 | 28 | type OutChat struct { 29 | ID int64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` 30 | Token string `protobuf:"bytes,2,opt,name=Token,proto3" json:"Token,omitempty"` 31 | ActorID string `protobuf:"bytes,3,opt,name=ActorID,proto3" json:"ActorID,omitempty"` 32 | ActorDisplayName string `protobuf:"bytes,4,opt,name=ActorDisplayName,proto3" json:"ActorDisplayName,omitempty"` 33 | Message string `protobuf:"bytes,5,opt,name=Message,proto3" json:"Message,omitempty"` 34 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 35 | XXX_unrecognized []byte `json:"-"` 36 | XXX_sizecache int32 `json:"-"` 37 | } 38 | 39 | func (m *OutChat) Reset() { *m = OutChat{} } 40 | func (m *OutChat) String() string { return proto.CompactTextString(m) } 41 | func (*OutChat) ProtoMessage() {} 42 | func (*OutChat) Descriptor() ([]byte, []int) { 43 | return fileDescriptor_fbedc122ac8e40eb, []int{0} 44 | } 45 | 46 | func (m *OutChat) XXX_Unmarshal(b []byte) error { 47 | return xxx_messageInfo_OutChat.Unmarshal(m, b) 48 | } 49 | func (m *OutChat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 50 | return xxx_messageInfo_OutChat.Marshal(b, m, deterministic) 51 | } 52 | func (m *OutChat) XXX_Merge(src proto.Message) { 53 | xxx_messageInfo_OutChat.Merge(m, src) 54 | } 55 | func (m *OutChat) XXX_Size() int { 56 | return xxx_messageInfo_OutChat.Size(m) 57 | } 58 | func (m *OutChat) XXX_DiscardUnknown() { 59 | xxx_messageInfo_OutChat.DiscardUnknown(m) 60 | } 61 | 62 | var xxx_messageInfo_OutChat proto.InternalMessageInfo 63 | 64 | func (m *OutChat) GetID() int64 { 65 | if m != nil { 66 | return m.ID 67 | } 68 | return 0 69 | } 70 | 71 | func (m *OutChat) GetToken() string { 72 | if m != nil { 73 | return m.Token 74 | } 75 | return "" 76 | } 77 | 78 | func (m *OutChat) GetActorID() string { 79 | if m != nil { 80 | return m.ActorID 81 | } 82 | return "" 83 | } 84 | 85 | func (m *OutChat) GetActorDisplayName() string { 86 | if m != nil { 87 | return m.ActorDisplayName 88 | } 89 | return "" 90 | } 91 | 92 | func (m *OutChat) GetMessage() string { 93 | if m != nil { 94 | return m.Message 95 | } 96 | return "" 97 | } 98 | 99 | type InChat struct { 100 | Token string `protobuf:"bytes,1,opt,name=Token,proto3" json:"Token,omitempty"` 101 | Message string `protobuf:"bytes,2,opt,name=Message,proto3" json:"Message,omitempty"` 102 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 103 | XXX_unrecognized []byte `json:"-"` 104 | XXX_sizecache int32 `json:"-"` 105 | } 106 | 107 | func (m *InChat) Reset() { *m = InChat{} } 108 | func (m *InChat) String() string { return proto.CompactTextString(m) } 109 | func (*InChat) ProtoMessage() {} 110 | func (*InChat) Descriptor() ([]byte, []int) { 111 | return fileDescriptor_fbedc122ac8e40eb, []int{1} 112 | } 113 | 114 | func (m *InChat) XXX_Unmarshal(b []byte) error { 115 | return xxx_messageInfo_InChat.Unmarshal(m, b) 116 | } 117 | func (m *InChat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 118 | return xxx_messageInfo_InChat.Marshal(b, m, deterministic) 119 | } 120 | func (m *InChat) XXX_Merge(src proto.Message) { 121 | xxx_messageInfo_InChat.Merge(m, src) 122 | } 123 | func (m *InChat) XXX_Size() int { 124 | return xxx_messageInfo_InChat.Size(m) 125 | } 126 | func (m *InChat) XXX_DiscardUnknown() { 127 | xxx_messageInfo_InChat.DiscardUnknown(m) 128 | } 129 | 130 | var xxx_messageInfo_InChat proto.InternalMessageInfo 131 | 132 | func (m *InChat) GetToken() string { 133 | if m != nil { 134 | return m.Token 135 | } 136 | return "" 137 | } 138 | 139 | func (m *InChat) GetMessage() string { 140 | if m != nil { 141 | return m.Message 142 | } 143 | return "" 144 | } 145 | 146 | func init() { 147 | proto.RegisterType((*OutChat)(nil), "nextcloudTalk.OutChat") 148 | proto.RegisterType((*InChat)(nil), "nextcloudTalk.InChat") 149 | } 150 | 151 | func init() { 152 | proto.RegisterFile("nextcloud_talk.proto", fileDescriptor_fbedc122ac8e40eb) 153 | } 154 | 155 | var fileDescriptor_fbedc122ac8e40eb = []byte{ 156 | // 258 bytes of a gzipped FileDescriptorProto 157 | 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x12, 0xc9, 0x4b, 0xad, 0x28, 158 | 0x49, 0xce, 0xc9, 0x2f, 0x4d, 0x89, 0x2f, 0x49, 0xcc, 0xc9, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 159 | 0x17, 0xe2, 0x85, 0x8b, 0x86, 0x00, 0x05, 0xa5, 0xa4, 0xd3, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 160 | 0xc1, 0x92, 0x49, 0xa5, 0x69, 0xfa, 0xa9, 0xb9, 0x05, 0x25, 0x95, 0x10, 0xb5, 0x4a, 0xfd, 0x8c, 161 | 0x5c, 0xec, 0xfe, 0xa5, 0x25, 0xce, 0x19, 0x89, 0x25, 0x42, 0x7c, 0x5c, 0x4c, 0x9e, 0x2e, 0x12, 162 | 0x8c, 0x0a, 0x8c, 0x1a, 0xcc, 0x41, 0x40, 0x96, 0x90, 0x08, 0x17, 0x6b, 0x48, 0x7e, 0x76, 0x6a, 163 | 0x9e, 0x04, 0x13, 0x50, 0x88, 0x33, 0x08, 0xc2, 0x11, 0x92, 0xe0, 0x62, 0x77, 0x4c, 0x2e, 0xc9, 164 | 0x2f, 0x02, 0x2a, 0x65, 0x06, 0x8b, 0xc3, 0xb8, 0x42, 0x5a, 0x5c, 0x02, 0x60, 0xa6, 0x4b, 0x66, 165 | 0x71, 0x41, 0x4e, 0x62, 0xa5, 0x5f, 0x62, 0x6e, 0xaa, 0x04, 0x0b, 0x58, 0x09, 0x86, 0x38, 0xc8, 166 | 0x14, 0xdf, 0xd4, 0xe2, 0xe2, 0xc4, 0xf4, 0x54, 0x09, 0x56, 0x88, 0x29, 0x50, 0xae, 0x92, 0x05, 167 | 0x17, 0x9b, 0x67, 0x1e, 0xd8, 0x3d, 0x70, 0xfb, 0x19, 0xd1, 0xec, 0x87, 0xe9, 0x64, 0x42, 0xd1, 168 | 0x69, 0xd4, 0xc5, 0xc8, 0xc5, 0xeb, 0x87, 0xec, 0x75, 0x21, 0x5b, 0x2e, 0xce, 0xa0, 0xd4, 0xc4, 169 | 0x14, 0x90, 0x69, 0xc5, 0x42, 0x62, 0x7a, 0x90, 0x80, 0xd0, 0x83, 0x05, 0x84, 0x9e, 0x2b, 0x28, 170 | 0x20, 0xa4, 0xc4, 0xf4, 0x50, 0xc2, 0x4b, 0x0f, 0x1a, 0x1c, 0x06, 0x8c, 0x42, 0x56, 0x5c, 0x9c, 171 | 0xe1, 0x45, 0x99, 0x25, 0xa9, 0x60, 0xd7, 0x88, 0xa2, 0x29, 0x83, 0x38, 0x52, 0x0a, 0x87, 0xa9, 172 | 0x49, 0x6c, 0x60, 0xbe, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x0d, 0xbd, 0x7e, 0x56, 0xa3, 0x01, 173 | 0x00, 0x00, 174 | } 175 | 176 | // Reference imports to suppress errors if they are not otherwise used. 177 | var _ context.Context 178 | var _ grpc.ClientConnInterface 179 | 180 | // This is a compile-time assertion to ensure that this generated file 181 | // is compatible with the grpc package it is being compiled against. 182 | const _ = grpc.SupportPackageIsVersion6 183 | 184 | // NextcloudTalkClient is the client API for NextcloudTalk service. 185 | // 186 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. 187 | type NextcloudTalkClient interface { 188 | ReadChats(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (NextcloudTalk_ReadChatsClient, error) 189 | WriteChat(ctx context.Context, in *InChat, opts ...grpc.CallOption) (*empty.Empty, error) 190 | } 191 | 192 | type nextcloudTalkClient struct { 193 | cc grpc.ClientConnInterface 194 | } 195 | 196 | func NewNextcloudTalkClient(cc grpc.ClientConnInterface) NextcloudTalkClient { 197 | return &nextcloudTalkClient{cc} 198 | } 199 | 200 | func (c *nextcloudTalkClient) ReadChats(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (NextcloudTalk_ReadChatsClient, error) { 201 | stream, err := c.cc.NewStream(ctx, &_NextcloudTalk_serviceDesc.Streams[0], "/nextcloudTalk.NextcloudTalk/ReadChats", opts...) 202 | if err != nil { 203 | return nil, err 204 | } 205 | x := &nextcloudTalkReadChatsClient{stream} 206 | if err := x.ClientStream.SendMsg(in); err != nil { 207 | return nil, err 208 | } 209 | if err := x.ClientStream.CloseSend(); err != nil { 210 | return nil, err 211 | } 212 | return x, nil 213 | } 214 | 215 | type NextcloudTalk_ReadChatsClient interface { 216 | Recv() (*OutChat, error) 217 | grpc.ClientStream 218 | } 219 | 220 | type nextcloudTalkReadChatsClient struct { 221 | grpc.ClientStream 222 | } 223 | 224 | func (x *nextcloudTalkReadChatsClient) Recv() (*OutChat, error) { 225 | m := new(OutChat) 226 | if err := x.ClientStream.RecvMsg(m); err != nil { 227 | return nil, err 228 | } 229 | return m, nil 230 | } 231 | 232 | func (c *nextcloudTalkClient) WriteChat(ctx context.Context, in *InChat, opts ...grpc.CallOption) (*empty.Empty, error) { 233 | out := new(empty.Empty) 234 | err := c.cc.Invoke(ctx, "/nextcloudTalk.NextcloudTalk/WriteChat", in, out, opts...) 235 | if err != nil { 236 | return nil, err 237 | } 238 | return out, nil 239 | } 240 | 241 | // NextcloudTalkServer is the server API for NextcloudTalk service. 242 | type NextcloudTalkServer interface { 243 | ReadChats(*empty.Empty, NextcloudTalk_ReadChatsServer) error 244 | WriteChat(context.Context, *InChat) (*empty.Empty, error) 245 | } 246 | 247 | // UnimplementedNextcloudTalkServer can be embedded to have forward compatible implementations. 248 | type UnimplementedNextcloudTalkServer struct { 249 | } 250 | 251 | func (*UnimplementedNextcloudTalkServer) ReadChats(req *empty.Empty, srv NextcloudTalk_ReadChatsServer) error { 252 | return status.Errorf(codes.Unimplemented, "method ReadChats not implemented") 253 | } 254 | func (*UnimplementedNextcloudTalkServer) WriteChat(ctx context.Context, req *InChat) (*empty.Empty, error) { 255 | return nil, status.Errorf(codes.Unimplemented, "method WriteChat not implemented") 256 | } 257 | 258 | func RegisterNextcloudTalkServer(s *grpc.Server, srv NextcloudTalkServer) { 259 | s.RegisterService(&_NextcloudTalk_serviceDesc, srv) 260 | } 261 | 262 | func _NextcloudTalk_ReadChats_Handler(srv interface{}, stream grpc.ServerStream) error { 263 | m := new(empty.Empty) 264 | if err := stream.RecvMsg(m); err != nil { 265 | return err 266 | } 267 | return srv.(NextcloudTalkServer).ReadChats(m, &nextcloudTalkReadChatsServer{stream}) 268 | } 269 | 270 | type NextcloudTalk_ReadChatsServer interface { 271 | Send(*OutChat) error 272 | grpc.ServerStream 273 | } 274 | 275 | type nextcloudTalkReadChatsServer struct { 276 | grpc.ServerStream 277 | } 278 | 279 | func (x *nextcloudTalkReadChatsServer) Send(m *OutChat) error { 280 | return x.ServerStream.SendMsg(m) 281 | } 282 | 283 | func _NextcloudTalk_WriteChat_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 284 | in := new(InChat) 285 | if err := dec(in); err != nil { 286 | return nil, err 287 | } 288 | if interceptor == nil { 289 | return srv.(NextcloudTalkServer).WriteChat(ctx, in) 290 | } 291 | info := &grpc.UnaryServerInfo{ 292 | Server: srv, 293 | FullMethod: "/nextcloudTalk.NextcloudTalk/WriteChat", 294 | } 295 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 296 | return srv.(NextcloudTalkServer).WriteChat(ctx, req.(*InChat)) 297 | } 298 | return interceptor(ctx, in, info, handler) 299 | } 300 | 301 | var _NextcloudTalk_serviceDesc = grpc.ServiceDesc{ 302 | ServiceName: "nextcloudTalk.NextcloudTalk", 303 | HandlerType: (*NextcloudTalkServer)(nil), 304 | Methods: []grpc.MethodDesc{ 305 | { 306 | MethodName: "WriteChat", 307 | Handler: _NextcloudTalk_WriteChat_Handler, 308 | }, 309 | }, 310 | Streams: []grpc.StreamDesc{ 311 | { 312 | StreamName: "ReadChats", 313 | Handler: _NextcloudTalk_ReadChats_Handler, 314 | ServerStreams: true, 315 | }, 316 | }, 317 | Metadata: "nextcloud_talk.proto", 318 | } 319 | -------------------------------------------------------------------------------- /pkg/protos/index.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package nextcloudTalk; 4 | 5 | import public "nextcloud_talk.proto"; -------------------------------------------------------------------------------- /pkg/protos/nextcloud_talk.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package nextcloudTalk; 4 | 5 | import "google/protobuf/empty.proto"; 6 | 7 | // NextcloudTalk is a Nextcloud Talk client. 8 | service NextcloudTalk { 9 | rpc ReadChats(google.protobuf.Empty) returns (stream OutChat); 10 | rpc WriteChat(InChat) returns (google.protobuf.Empty); 11 | } 12 | 13 | message OutChat { 14 | int64 ID = 1; 15 | string Token = 2; 16 | string ActorID = 3; 17 | string ActorDisplayName = 4; 18 | string Message = 5; 19 | } 20 | 21 | message InChat { 22 | string Token = 1; 23 | string Message = 2; 24 | } -------------------------------------------------------------------------------- /pkg/services/nextcloud_talk.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | //go:generate mkdir -p ../protos/generated 4 | //go:generate sh -c "protoc --go_out=paths=source_relative,plugins=grpc:../protos/generated -I=../protos ../protos/*.proto" 5 | 6 | import ( 7 | "context" 8 | 9 | empty "github.com/golang/protobuf/ptypes/empty" 10 | "github.com/pojntfx/nextcloud-talk-bot-framework/pkg/clients" 11 | nextcloudTalk "github.com/pojntfx/nextcloud-talk-bot-framework/pkg/protos/generated" 12 | ) 13 | 14 | // NextcloudTalk is a Nextcloud Talk client. 15 | type NextcloudTalk struct { 16 | nextcloudTalk.UnimplementedNextcloudTalkServer 17 | chatRequestChan chan bool 18 | chatResponseChan chan chan clients.Chat 19 | statusChan chan string 20 | writeChat func(token, message string) error 21 | } 22 | 23 | // NewNextcloudTalk creates a new Nextcloud Talk Client. 24 | func NewNextcloudTalk(chatRequestChan chan bool, chatResponseChan chan chan clients.Chat, statusChan chan string, writeChat func(token, message string) error) *NextcloudTalk { 25 | return &NextcloudTalk{ 26 | chatRequestChan: chatRequestChan, 27 | chatResponseChan: chatResponseChan, 28 | statusChan: statusChan, 29 | writeChat: writeChat, 30 | } 31 | } 32 | 33 | // ReadChats reads the chats. 34 | func (n *NextcloudTalk) ReadChats(req *empty.Empty, srv nextcloudTalk.NextcloudTalk_ReadChatsServer) error { 35 | n.chatRequestChan <- true 36 | 37 | readChan := <-n.chatResponseChan 38 | 39 | for chat := range readChan { 40 | go func(ichat *clients.Chat) { 41 | if err := srv.Send(&nextcloudTalk.OutChat{ 42 | ID: int64(ichat.ID), 43 | Token: ichat.Token, 44 | ActorID: ichat.ActorID, 45 | ActorDisplayName: ichat.ActorDisplayName, 46 | Message: ichat.Message, 47 | }); err != nil { 48 | n.statusChan <- err.Error() 49 | } 50 | }(&chat) 51 | } 52 | 53 | return nil 54 | } 55 | 56 | // WriteChat writes a chat. 57 | func (n *NextcloudTalk) WriteChat(ctx context.Context, req *nextcloudTalk.InChat) (*empty.Empty, error) { 58 | if err := n.writeChat(req.GetToken(), req.GetMessage()); err != nil { 59 | return &empty.Empty{}, err 60 | } 61 | 62 | return &empty.Empty{}, nil 63 | } 64 | -------------------------------------------------------------------------------- /usr/lib/systemd/system/nctalkproxyd.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Nextcould Talk proxy daemon 3 | After=network.target network-online.target nss-lockup.target 4 | 5 | [Service] 6 | #Environment="NCTALKPROXYD_DBPATH=/var/lib/nctalkproxyd" 7 | #Environment="NCTALKPROXYD_USERNAME=botusername" 8 | #Environment="NCTALKPROXYD_PASSWORD=botpassword" 9 | #Environment="NCTALKPROXYD_ADDRREMOTE=https://mynextcloud.com" 10 | RuntimeDirectory=nctalkproxyd 11 | RuntimeDirectoryMode=750 12 | 13 | Type=simple 14 | # oneshot 15 | ExecStart=/usr/bin/nctalkproxyd -f /etc/nctalkproxyd.yaml 16 | 17 | [Install] 18 | WantedBy=multi-user.target 19 | --------------------------------------------------------------------------------